Переглянути джерело

v.mkgrid and v.vect.stats: add examples with hexagons

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@69167 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 8 роки тому
батько
коміт
59f5d1ebde

+ 1 - 0
vector/v.mkgrid/main.c

@@ -71,6 +71,7 @@ int main(int argc, char *argv[])
     G_add_keyword(_("geometry"));
     G_add_keyword(_("grid"));
     G_add_keyword(_("point pattern"));
+    G_add_keyword(_("hexagon"));
     module->description = _("Creates a vector map of a user-defined grid.");
 
     vectname = G_define_standard_option(G_OPT_V_OUTPUT);

+ 46 - 0
vector/v.mkgrid/v.mkgrid.html

@@ -129,6 +129,52 @@ d.grid 5000
 Hexagon map
 </center>
 
+<h3>Using hexagons for point density</h3>
+
+To compute point density in a hexagonal grid for the vector map
+<em>points_of_interest</em> in the basic North Carolina sample dataset,
+the vector map itself is used to set extent of the computational region.
+The resolution is based on the desired size of hexagons.
+
+<div class="code"><pre>
+g.region vector=points_of_interest res=2000 -pa
+</pre></div>
+
+The hexagonal grid is created as a vector map based on the previously
+selected extent and size of the grid.
+
+<div class="code"><pre>
+v.mkgrid map=hexagons -h
+</pre></div>
+
+The following counts the number of points per hexagon using the
+<em><a href="v.vect.stats.html">v.vect.stats</a></em> module.
+
+<div class="code"><pre>
+v.vect.stats points=points_of_interest areas=hexagons count_column=count
+</pre></div>
+
+User should note that some of the points may be outside the grid
+since the hexagons cannot cover all the area around the edges
+(the computational region extent needs to be enlarged if all points
+should be considered).
+The last command sets the vector map color table to <tt>viridis</tt>
+based on the <tt>count</tt> column.
+
+<div class="code"><pre>
+v.colors map=hexagons use=attr column=count color=viridis
+</pre></div>
+
+<!--
+d.erase 77:77:77
+mogrify -trim .png
+-->
+
+<center>
+<img src="v_mkgrid.png"><br>
+Point density in a hexagonal grid
+</center>
+
 <h2>SEE ALSO</h2>
 
 <em>

BIN
vector/v.mkgrid/v_mkgrid.png


+ 83 - 0
vector/v.vect.stats/v.vect.stats.html

@@ -145,6 +145,89 @@ v.vect.stats points=rand5000 area=myzipcodes_wake count_column=num_points \
 v.db.select myzipcodes_wake column=ZIPCODE_,ZIPNAME,avg_elev
 </pre></div>
 
+<h3>Point statistics in a hexagonal grid</h3>
+
+The grid extent and size is influenced by the current computational
+region. The extent is based on the vector map
+<em>points_of_interest</em> from the basic North Carolina sample dataset.
+
+<div class="code"><pre>
+g.region vector=points_of_interest res=2000 -pa
+</pre></div>
+
+The hexagonal grid is created as a vector map based on the previously
+selected extent and size of the grid.
+
+<div class="code"><pre>
+v.mkgrid map=hexagons -h
+</pre></div>
+
+The <em><a href="v.vect.stats.html">v.vect.stats</a></em> module
+counts the number of points and does one statistics on a selected
+column (here: <em>elev_m</em>).
+
+<div class="code"><pre>
+v.vect.stats points=points_of_interest areas=hexagons method=average \
+  points_column=elev_m count_column=count stats_column=average
+</pre></div>
+
+User should note that some of the points may be outside the grid
+since the hexagons cannot cover all the area around the edges
+(the computational region extent needs to be enlarged if all points
+should be considered).
+The last command sets the vector map color table to <tt>viridis</tt>
+based on the <tt>count</tt> column.
+
+<div class="code"><pre>
+v.colors map=hexagons use=attr column=average color=viridis
+</pre></div>
+
+<!--
+v.vect.stats points=points_of_interest areas=hexagons method=average \
+  points_column=elev_m count_column=count stats_column=average
+v.vect.stats points=points_of_interest areas=hexagons method=range \
+  points_column=elev_m count_column=count stats_column=range
+v.vect.stats points=points_of_interest areas=hexagons method=stddev \
+  points_column=elev_m count_column=count stats_column=stddev
+
+export GRASS_FONT=LiberationSans-Regular
+
+FILE=v_vect_stats.png
+
+rm $FILE
+
+d.mon cairo out=$FILE
+
+d.frame frame=f1 at=50,100,0,50 -c
+v.colors map=hexagons use=attr column=range color=viridis
+d.vect map=points_of_interest color=black fill_color=black width=1 icon=basic/point size=3
+d.text text="points" at=60,5 size=10 color=black
+
+d.frame frame=f2 at=50,100,50,100 -c
+v.colors map=hexagons use=attr column=count color=viridis
+d.vect map=hexagons where="count > 0"
+d.text text="count" at=60,5 size=10 color=black
+
+d.frame frame=f3 at=0,50,0,50 -c
+v.colors map=hexagons use=attr column=average color=viridis
+d.vect map=hexagons where="count > 0"
+d.text text="average" at=60,5 size=10 color=black
+
+d.frame frame=f4 at=0,50,50,100 -c
+v.colors map=hexagons use=attr column=stddev color=viridis
+d.vect map=hexagons where="count > 0"
+d.text text="stddev" at=60,5 size=10 color=black
+
+d.mon stop=cairo
+mogrify -trim $FILE
+-->
+
+<center>
+<img src="v_vect_stats.png"><br>
+Point statistics in a hexagonal grid (count of points, average of values
+associated with point, standard deviation)
+</center>
+
 
 <h2>SEE ALSO</h2>
 

BIN
vector/v.vect.stats/v_vect_stats.png