[GRASS-SVN] r71659 - grass-addons/grass7/raster/r.gsflow.hydrodem

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Nov 10 19:15:49 PST 2017


Author: awickert
Date: 2017-11-10 19:15:48 -0800 (Fri, 10 Nov 2017)
New Revision: 71659

Modified:
   grass-addons/grass7/raster/r.gsflow.hydrodem/r.gsflow.hydrodem.html
   grass-addons/grass7/raster/r.gsflow.hydrodem/r.gsflow.hydrodem.py
Log:
r.gsflow.hydrodem grid alignment

Modified: grass-addons/grass7/raster/r.gsflow.hydrodem/r.gsflow.hydrodem.html
===================================================================
--- grass-addons/grass7/raster/r.gsflow.hydrodem/r.gsflow.hydrodem.html	2017-11-10 20:51:55 UTC (rev 71658)
+++ grass-addons/grass7/raster/r.gsflow.hydrodem/r.gsflow.hydrodem.html	2017-11-11 03:15:48 UTC (rev 71659)
@@ -9,9 +9,8 @@
 glaciated watersheds to climate change, in AGU Fall Meeting Abstracts, H13L–1590, San
 Francisco, CA.
 
-<h2>AUTHORS</h2>
+<h2>SEE ALSO</h2>
 
-Andrew D. Wickert<br>LSO</h2>
 <a href="v.gsflow.export">v.gsflow.export</a>
 <a href="v.gsflow.gravres">v.gsflow.gravres</a>
 <a href="v.gsflow.hruparams">v.gsflow.hruparams</a>
@@ -21,4 +20,8 @@
 <a href="v.stream.inbasin">v.stream.inbasin</a>
 <a href="v.stream.network">v.stream.network</a>
 
+<h2>AUTHORS</h2>
+
+Andrew D. Wickert<br>
+
 <p><i>Last changed: $Date 2016-09-27$</i>

Modified: grass-addons/grass7/raster/r.gsflow.hydrodem/r.gsflow.hydrodem.py
===================================================================
--- grass-addons/grass7/raster/r.gsflow.hydrodem/r.gsflow.hydrodem.py	2017-11-10 20:51:55 UTC (rev 71658)
+++ grass-addons/grass7/raster/r.gsflow.hydrodem/r.gsflow.hydrodem.py	2017-11-11 03:15:48 UTC (rev 71659)
@@ -49,12 +49,6 @@
 #%  required: yes
 #%end
 
-#%option
-#%  key: resolution
-#%  label: Target MODFLOW grid resolution
-#%  required: yes
-#%end
-
 #%option G_OPT_R_OUTPUT
 #%  key: streams_modflow
 #%  label: Stream network at MODFLOW grid resolution
@@ -111,18 +105,29 @@
     dem = options['dem']
     grid = options['grid']
     streams = options['streams']
-    resolution = float(options['resolution'])
+    #resolution = float(options['resolution'])
     streams_MODFLOW = options['streams_modflow']
     DEM_MODFLOW = options['dem_modflow']
     
     gscript.use_temp_region()
     
-    g.region(raster=dem)
-    g.region(vector=grid)
+    # Get number of rows and columns
+    colNames = np.array(gscript.vector_db_select(grid, layer=1)['columns'])
+    colValues = np.array(gscript.vector_db_select(grid, layer=1)['values'].values())
+    cats = colValues[:,colNames == 'cat'].astype(int).squeeze()
+    rows = colValues[:,colNames == 'row'].astype(int).squeeze()
+    cols = colValues[:,colNames == 'col'].astype(int).squeeze()
+    nRows = np.max(rows)
+    nCols = np.max(cols)
+    
+    # Set the region
+    g.region(vector=grid, rows=nRows, cols=nCols)
+
+    #g.region(raster=dem)
     v.to_rast(input=streams, output=streams_MODFLOW, use='val', value=1.0,
               type='line', overwrite=gscript.overwrite(), quiet=True)
     r.mapcalc(streams_MODFLOW+" = "+streams_MODFLOW+" * DEM", overwrite=True)
-    g.region(res=resolution, quiet=True)
+    #g.region(res=resolution, quiet=True)
     r.resamp_stats(input=streams_MODFLOW, output=streams_MODFLOW, 
                    method='minimum', overwrite=gscript.overwrite(), quiet=True)
     r.resamp_stats(input=dem, output=DEM_MODFLOW, method='average',



More information about the grass-commit mailing list