[GRASS-SVN] r58741 - in grass/trunk: lib/python/temporal temporal/t.rast.import

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jan 17 15:30:14 PST 2014


Author: huhabla
Date: 2014-01-17 15:30:14 -0800 (Fri, 17 Jan 2014)
New Revision: 58741

Modified:
   grass/trunk/lib/python/temporal/stds_import.py
   grass/trunk/temporal/t.rast.import/t.rast.import.py
Log:
Added flag to set the computational region after import of raster maps.


Modified: grass/trunk/lib/python/temporal/stds_import.py
===================================================================
--- grass/trunk/lib/python/temporal/stds_import.py	2014-01-17 19:45:38 UTC (rev 58740)
+++ grass/trunk/lib/python/temporal/stds_import.py	2014-01-17 23:30:14 UTC (rev 58741)
@@ -53,7 +53,8 @@
 ############################################################################
 
 
-def _import_raster_maps_from_gdal(maplist, overr, exp, location, link, format_):
+def _import_raster_maps_from_gdal(maplist, overr, exp, location, link, format_, 
+                                  set_current_region=False):
     impflags = ""
     if overr:
         impflags += "o"
@@ -93,10 +94,14 @@
                 core.fatal(_("Unable to set the color rules for "
                              "raster map <%s>.") % name)
 
+    # Set the computational region from the last map imported
+    if set_current_region is True:
+        core.run_command("g.region", rast=name)
+
 ############################################################################
 
 
-def _import_raster_maps(maplist):
+def _import_raster_maps(maplist, set_current_region=False):
     # We need to disable the projection check because of its
     # simple implementation
     impflags = "o"
@@ -113,6 +118,10 @@
             core.fatal(_("Unable to unpack raster map <%s> from file %s.") % (name, 
                                                                               filename))
 
+    # Set the computational region from the last map imported
+    if set_current_region is True:
+        core.run_command("g.region", rast=name)
+
 ############################################################################
 
 
@@ -162,7 +171,8 @@
 
 
 def import_stds(input, output, extrdir, title=None, descr=None, location=None,
-        link=False, exp=False, overr=False, create=False, stds_type="strds", base=None):
+        link=False, exp=False, overr=False, create=False, stds_type="strds", 
+        base=None, set_current_region=False):
     """!Import space time datasets of type raster and vector
 
         @param input Name of the input archive file
@@ -390,10 +400,10 @@
         # Import the maps
         if type_ == "strds":
             if format_ == "GTiff" or format_ == "AAIGrid":
-                _import_raster_maps_from_gdal(
-                    maplist, overr, exp, location, link, format_)
+                _import_raster_maps_from_gdal(maplist, overr, exp, location, 
+                                              link, format_, set_current_region)
             if format_ == "pack":
-                _import_raster_maps(maplist)
+                _import_raster_maps(maplist, set_current_region)
         elif type_ == "stvds":
             if format_ == "GML":
                 _import_vector_maps_from_gml(

Modified: grass/trunk/temporal/t.rast.import/t.rast.import.py
===================================================================
--- grass/trunk/temporal/t.rast.import/t.rast.import.py	2014-01-17 19:45:38 UTC (rev 58740)
+++ grass/trunk/temporal/t.rast.import/t.rast.import.py	2014-01-17 23:30:14 UTC (rev 58741)
@@ -56,6 +56,11 @@
 #%end
 
 #%flag
+#% key: r
+#% description: Set the current region from the last map that was imported
+#%end
+
+#%flag
 #% key: l
 #% description: Link the raster files using r.external
 #%end
@@ -93,6 +98,7 @@
     descr = options["description"]
     location = options["location"]
     base = options["base"]
+    set_current_region = flags["r"]
     link = flags["l"]
     exp = flags["e"]
     overr = flags["o"]
@@ -101,7 +107,8 @@
     tgis.init()
 
     tgis.import_stds(input, output, extrdir, title, descr, location,
-                     link, exp, overr, create, "strds", base)
+                     link, exp, overr, create, "strds", base, 
+                     set_current_region)
 
 if __name__ == "__main__":
     options, flags = grass.parser()



More information about the grass-commit mailing list