Skip to content

Commit

Permalink
i.sentinel.import addon: round to CELL (#132)
Browse files Browse the repository at this point in the history
Round Sentinel-2 bands to CELL in case of reprojection.

Fixes #127

Co-authored-by: Markus Neteler <neteler@mundialis.de>
  • Loading branch information
neteler and neteler committed Mar 26, 2020
1 parent c081507 commit 1c22f3c
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,13 @@ def _import_file(self, filename, module, args):
args['resolution_value'] = self._raster_resolution(filename)
try:
gs.run_command(module, input=filename, output=mapname, **args)
if gs.raster_info(mapname)['datatype'] in ('FCELL', 'DCELL'):
gs.message('Rounding to integer after reprojection')
gs.use_temp_region()
gs.run_command('g.region', raster=mapname)
gs.run_command('r.mapcalc', quiet=True, expression='tmp_%s = round(%s)' % (mapname, mapname))
gs.run_command('g.rename', quiet=True, overwrite=True, raster='tmp_%s,%s' % (mapname, mapname))
gs.del_temp_region()
gs.raster_history(mapname)
except CalledModuleError as e:
pass # error already printed
Expand Down

0 comments on commit 1c22f3c

Please sign in to comment.