[GRASS-SVN] r72170 - grass-addons/grass7/raster/r.sentinel/r.sentinel.import
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Jan 28 06:47:02 PST 2018
Author: martinl
Date: 2018-01-28 06:47:02 -0800 (Sun, 28 Jan 2018)
New Revision: 72170
Modified:
grass-addons/grass7/raster/r.sentinel/r.sentinel.import/r.sentinel.import.py
Log:
r.sentinel.import: add -o for reprojecting data
Modified: grass-addons/grass7/raster/r.sentinel/r.sentinel.import/r.sentinel.import.py
===================================================================
--- grass-addons/grass7/raster/r.sentinel/r.sentinel.import/r.sentinel.import.py 2018-01-28 10:47:25 UTC (rev 72169)
+++ grass-addons/grass7/raster/r.sentinel/r.sentinel.import/r.sentinel.import.py 2018-01-28 14:47:02 UTC (rev 72170)
@@ -31,6 +31,10 @@
#% description: File name pattern to import
#%end
#%flag
+#% key: o
+#% description: Reproject raster data using r.import if needed
+#%end
+#%flag
#% key: l
#% description: Link raster data instead of importing
#%end
@@ -38,7 +42,9 @@
#% key: c
#% description: Import cloud masks as vector maps
#%end
-
+#%rules
+#% exclusive: -l,-o
+#%end
import os
import sys
import re
@@ -76,17 +82,21 @@
return files
- def import_products(self, link=False):
+ def import_products(self, reproject=False, link=False):
+ if link:
+ module = 'r.external'
+ else:
+ if reproject:
+ module = 'r.import'
+ else:
+ module = 'r.in.gdal'
+
for f in self.files:
- self._import_file(f, link)
+ self._import_file(f, module)
- def _import_file(self, filename, link=False):
- module = 'r.external' if link else 'r.import'
+ def _import_file(self, filename, module):
mapname = os.path.splitext(os.path.basename(filename))[0]
- if link:
- gs.message('Linking <{}>...'.format(mapname))
- else:
- gs.message('Importing <{}>...'.format(mapname))
+ gs.message('Processing <{}>...'.format(mapname))
try:
gs.run_command(module, input=filename, output=mapname)
except CalledModuleError as e:
@@ -113,7 +123,7 @@
importer.filter(options['pattern'])
- importer.import_products(flags['l'])
+ importer.import_products(flags['o'], flags['l'])
if flags['c']:
importer.import_cloud_masks()
More information about the grass-commit
mailing list