[GRASS-SVN] r60655 - grass/branches/releasebranch_7_0/raster/r.univar

svn_grass at osgeo.org svn_grass at osgeo.org
Sat May 31 15:58:08 PDT 2014


Author: neteler
Date: 2014-05-31 15:58:08 -0700 (Sat, 31 May 2014)
New Revision: 60655

Modified:
   grass/branches/releasebranch_7_0/raster/r.univar/r.univar.html
Log:
r.univar manual: new NC example; cleanup of commented draft examples since v.rast.stats does the job

Modified: grass/branches/releasebranch_7_0/raster/r.univar/r.univar.html
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.univar/r.univar.html	2014-05-31 22:57:58 UTC (rev 60654)
+++ grass/branches/releasebranch_7_0/raster/r.univar/r.univar.html	2014-05-31 22:58:08 UTC (rev 60655)
@@ -33,80 +33,28 @@
 <p>
 Without a <b>zones</b> input raster, the <em>r.quantile</em> module will
 be significantly more efficient for calculating percentiles with large maps.
+<p>
+For calculating univariate statistics from a raster map based on vector polygon
+map and uploads statistics to new attribute columns, see
+<em><a href="v.rast.stats.html">v.rast.stats</a></em>.
 
 <h2>EXAMPLE</h2>
 
-Calculate the raster statistics for zones within a vector map coverage
-and upload the results for mean, min and max back to the vector map:
+Calculate the raster statistics for zones within a raster polygon map 
+coverage (basins, North Carolina sample dataset):
 
 <div class="code"><pre>
-#### set the raster region to match the map
-g.region vect=fields res=10 -ap
+# set computational region
+g.region rast=basin -p
 
-#### create rasterized version of vector map
-v.to.rast in=fields out=fields.10m use=cat type=area labelcolumn=label
-r.colors fields.10m color=random
+# check basin IDs
+r.category basin
 
-#### perform analysis
-r.univar -t map=elevation.10m zones=fields.10m | \
-  cut -f1,5,6,8 -d'|' > fields_stats.txt
-
-
-#### populate vector DB with stats
-
-# create working copy of vector map
-g.copy vect=fields,fields_stats
-
-# create new attribute columns to hold output
-v.db.addcol map=fields_stats \
-  columns='mean_elev DOUBLE PRECISION, min_elev DOUBLE PRECISION, max_elev DOUBLE PRECISION'
-
-# create SQL command file, and execute it
-sed -e '1d' fields_stats.txt | awk -F'|' \
-  '{print "UPDATE fields_stats SET min_elev = "$2", max_elev = "$3", \
-  mean_elev = "$4" WHERE cat = "$1";"}' \
-   > fields_stats_sqlcmd.txt
-
-db.execute input=fields_stats_sqlcmd.txt
-<!--
-
-###### alternate method with db.in.ogr:  (needs work) ######
-
-#### convert text file table to a database table
-# not safe for commas in the label
-tr '|' ',' < fields_stats.txt > fields_stats.csv
-echo '"Integer","String","Real","Real","Real"' > fields_stats.csvt
-
-# import table
-db.in.ogr dsn=fields_stats.csv output=fields_data
-
-# view table
-db.select fields_data
-
-# remove temporary files
-rm fields_stats.csv fields_stats.csvt fields_stats.txt
-
-
-#### populate vector DB with stats
-
-# create working copy of vector map
-g.copy vect=fields,fields_stats
-
-# create new attribute columns to hold output
-v.db.addcol map=fields_stats \
-  columns='mean_elev DOUBLE PRECISION, min_elev DOUBLE PRECISION, max_elev DOUBLE PRECISION'
-
-# perform DB step  (broken)
-## how to automatically collate by key column, ie copy between tables?
-## SELECT INTO? JOIN?
-echo "INSERT INTO fields_stats (mean_elev,min_elev,max_elev) SELECT mean,min,max FROM fields_data" | db.execute
--->
-
-#### view completed table
-v.db.select fields_stats
+#### perform analysis with elevation map (extent and res. match)
+r.univar -t map=elevation zones=basin separator=comma \
+         output=basin_elev_zonal.csv
 </pre></div>
 
-
 <h2>TODO</h2>
 
 <i>mode, skewness, kurtosis</i>



More information about the grass-commit mailing list