Skip to main content

A Python library for making geographic hexagon grids like QGIS's `create grid` function

Project description

A Python 3.9+ library for making geographic hexagon grids like QGIS’s create grid function. Not designed for making discrete global grid systems like Uber’s H3.

Here’s an example of its main use, namely, minimally covering a GeoDataFrame of features with a flat-top hexagon grid of given resolution.

import geopandas as gpd
import geohexgrid as ghg

# Load New Zealand territorial authorities projected in EPSG 2193 (NZTM)
shapes = gpd.read_file(DATA_DIR / "nz_tas.gpkg")

# Cover it minimally with hexagons of circumradius 10 kilometres
grid = ghg.make_grid(shapes, 10_000, intersect=True)

# Plot
base = shapes.plot(color='red', figsize=(20, 20), aspect="equal")
grid.plot(ax=base, color='white', edgecolor="blue", alpha=0.5)
hexagon grid of 10,000-metre circumradius covering New Zealand

Contributors

  • Alex Raichev (2014-09), maintainer

Installation

Install from PyPI, e.g. via poetry add geohexgrid.

Examples

See the Jupyter notebook at notebooks/examples.ipynb.

Notes

  • This project’s development status is Alpha. Alex uses this project for work and changes it breakingly when it suits his needs.

  • This project uses semantic versioning.

  • Thanks to MRCagney for periodically funding this project.

  • Red Blog Games has a great write up of non-geographic hexagon grids.

  • Alex wanted to chose a shorter name for this package, such as ‘hexgrid’, ‘geohex’, or ‘hexcover’, but those were already taken or too close to taken on PyPI.

Changes

1.1.0, 2023-10-27

  • Added the clip option to the function grid_from_gdf.

  • Updated dependencies.

  • Re-ordered functions.

  • Changed the cell ID separotor to a comma.

1.0.0, 2022-08-15

  • First release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geohexgrid-1.1.0.tar.gz (6.8 kB view hashes)

Uploaded Source

Built Distribution

geohexgrid-1.1.0-py3-none-any.whl (6.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page