Skip to content

A class that generates a hexagon grid in longitude and latitude

License

Notifications You must be signed in to change notification settings

bkenne/geojson-hexagon-grid-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

geojson-hexagon-grid-builder

A simple class that generates a hexagon grid in longitude and latitude given a couple of basic parameters. It applys the Haversine formula to adjust size of grid to the latitude it is required. Note, it was intended to build a grid covering a finite geographic area, such as at the landownership level or within the proximity of the latitude selected. The GeoJson file that can be written out contains basic properties for each hexagon generated (e.g. the center point, call date, and a counter id).

Parameters Required

  • list of coordinates for bounding box in longitude and latitude (i.e. lower left and upper right) Example: [-96.8211773, 32.9655743, -96.8190795, 32.9672722]
  • numeric for kilometers for radius of hexagon, such as 0.015 for 15 meters
  • string parameter "kilometer" - currently doesn't have any other unit conversions, such as feet, miles, etc.

Installation

Simply add the attached python file to your work.

Requirements

  • import math
  • import time
  • import json

Example Usage:

Call the class:
hexgrid = Hexbuild([-96.8211773, 32.9655743, -96.8190795, 32.9672722], 0.015, "kilometers")

Write the results out to a file for use:
geofile = open(r"c:\temp\testhex.json", "w")
geofile.write(hexgrid.sendGeoJsonText())
geofile.close()

{Also attached is a jupyter notebook that you can see how to apply some spatial intresections with the resulting hexagrid}



Open the file in your favorite viewer, like ArcGIS Pro, QGIS, etc.:
Here at 0.015 kilometers
Image
Here at 0.05 kilometers
Image
Enjoy if it is helpful to you!

Releases

No releases published

Packages

No packages published