[GRASS-dev] G7: v.mkhexgrid addon for hexagon creation

Hi,

I have added v.mkhexgrid as new G7 addon to the Addons repo. The
original author is Trevor Wiens who already implemented it as a Python
script. I made some minor changes to get it running in GRASS GIS 7.
Screenshot:
https://svn.osgeo.org/grass/grass-addons/grass7/vector/v.mkhexgrid/v_mkhexgrid.png

Originally I had hoped that v.voronoi would do the job but it does not
create proper hexagons. I was running:

# desired result:
http://blogs.esri.com/esri/arcgis/files/2013/05/fig3.png (3rd figure
within)
# create first set of points
g.region rast=elevation -p
v.mkgrid -p map=pointpattern1 grid=13,15 position=region breaks=1
# shift grid by half point distance
g.region n=n+500 w=w+500 e=e+500 s=s+500 -p
# create second set of points
v.mkgrid -p map=pointpattern2 grid=13,15 position=region breaks=1
# merge into final point pattern
v.patch input=pointpattern1,pointpattern2 output=pointpattern3
# generate Thiessen, hoping for hexagons
v.voronoi input=pointpattern3 out=hexagon_attempt
# show result
d.mon wx0
sleep 5
d.vect hexagon_attempt type=boundary

(screenshot attached).

In essence, the Addon v.mkhexgrid does the job but it is very CPU/disk
space demanding.

Markus

(attachments)

v_voronoi_no_hexagon1.png

On Thu, Nov 20, 2014 at 12:29 AM, Markus Neteler <neteler@osgeo.org> wrote:

Hi,

I have added v.mkhexgrid as new G7 addon to the Addons repo. The
original author is Trevor Wiens who already implemented it as a Python
script. I made some minor changes to get it running in GRASS GIS 7.
Screenshot:
https://svn.osgeo.org/grass/grass-addons/grass7/vector/v.mkhexgrid/v_mkhexgrid.png

Originally I had hoped that v.voronoi would do the job but it does not
create proper hexagons. I was running:

# desired result:
http://blogs.esri.com/esri/arcgis/files/2013/05/fig3.png (3rd figure
within)
# create first set of points
g.region rast=elevation -p
v.mkgrid -p map=pointpattern1 grid=13,15 position=region breaks=1
# shift grid by half point distance
g.region n=n+500 w=w+500 e=e+500 s=s+500 -p
# create second set of points
v.mkgrid -p map=pointpattern2 grid=13,15 position=region breaks=1
# merge into final point pattern
v.patch input=pointpattern1,pointpattern2 output=pointpattern3
# generate Thiessen, hoping for hexagons
v.voronoi input=pointpattern3 out=hexagon_attempt
# show result
d.mon wx0
sleep 5
d.vect hexagon_attempt type=boundary

The points are not "cleverly spaced". Attached is a python script that
generates center points of hexagons. The output of v.voronoi shows now
hexagons.

Markus M

(attachments)

hexagon_centers.py (618 Bytes)

On Thu, Nov 20, 2014 at 9:52 AM, Markus Metz
<markus.metz.giswork@gmail.com> wrote:
...

The points are not "cleverly spaced". Attached is a python script that
generates center points of hexagons. The output of v.voronoi shows now
hexagons.

Cool! Do you have a reference for ""cleverly spaced"? Just came across
http://en.wikipedia.org/wiki/Hexagonal_lattice
http://en.wikipedia.org/wiki/Hexagonal_tiling

Overall, this point generator might be a nice extension to v.mkgrid.

Markus

On Thu, Nov 20, 2014 at 10:31 AM, Markus Neteler <neteler@osgeo.org> wrote:

On Thu, Nov 20, 2014 at 9:52 AM, Markus Metz
<markus.metz.giswork@gmail.com> wrote:
...

The points are not "cleverly spaced". Attached is a python script that
generates center points of hexagons. The output of v.voronoi shows now
hexagons.

Cool! Do you have a reference for ""cleverly spaced"? Just came across
http://en.wikipedia.org/wiki/Hexagonal_lattice
http://en.wikipedia.org/wiki/Hexagonal_tiling

Overall, this point generator might be a nice extension to v.mkgrid.

For the record: Markus Metz kindly implemented hexagons in v.mkgrid (thanks!)

http://grass.osgeo.org/grass70/manuals/v.mkgrid.html
-h Create hexagons (default: rectangles)

(an example with screenshot will be online in 1-2hs from now, the
manual is building again at time)

markusN

PS: I removed the G7 Addon since no longer needed. And v.mkgrid is WAY faster...