Geospatial Modelling Environment

genhexagonsinpolys (Generate Hexagons In Polygons)

Generates a regular arrangement of hexagons within the bounds of polygons


This tool generates a regular arrangement of hexagons within the bounds of each polygon in a polygon data source. The user specifies the dimension of the hexagons (a constant) and the amount of spacing between adjacent hexagons. Only hexagons that are completely contained by each polygon are retained. Note that if the polygons overlap, then the resulting hexagons are also likely to overlap. If this tool does not suit your purpose you may find the ‘genshapes’ command more useful – it will also generate a regular arrangement of hexagons but without the constraint that the hexagons must be completely contained by the polygon. Also, the gencirclesinpolys command serves a similar function to this tool but using circles instead of hexagons.

There is an element of randomisation built into this tool: the overall placement of the hexagon grid is determined randomly so that if you run the tool twice, you will get a different result. This is important because it allows you to run the tool many times in an attempt to find the maximum number of hexagons that can fit in a given polygon. This will depend on the complex shape of the polygon and generally cannot be determined analytically.

Note that hexagons mesh together perfectly to completely cover space with no overlap and with no interstitial spaces between hexagons (unlike circles). However, the ‘spacing’ option does allow you to add overlap (a negative value) or increase the spacing between hexagons (a positive value).

One possible application of this tool might be estimating the number of viable home ranges that an area might contain.


genhexagonsinpolys(in, uidfield, out, dimension, [spacing], [where]);

inthe input polygon data source
uidfieldthe unique ID field of the input feature data source
outthe output polygon data source
dimensionthe distance from the centre of the hexagon to the middle of one of the six edges that define the hexagon (a constant specified in the coordinate system units of the reference layer)
[spacing]the additional distance to add between hexagons (default= 0, which implies no interstitial spaces between hexagons; a negative value results in hexagon overlap)
[where]the selection statement that will be applied to the feature data source to identify a subset of features to process (see full Help documentation for further details)


genhexagonsinpolys(in=”C:datareferencelayer.shp”, out=”C:datamyoutput.shp”, dimension=100);

genhexagonsinpolys(in=”C:databoundaries.shp”, out=”C:datamyoutput.shp”, dimension=100, dimension=30);


Please consider making a purchase to support the continued development of these tools  Read more...

Tips on how to use this interface efficiently 


Open Source GIS

Copyright © 2001-2014 Hawthorne L. Beyer, Ph.D., Spatial Ecology LLC    Connect on LinkedIn