
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
A Python library for making geographic flat-top hexagon grids like QGIS's `create grid` function
Geohexgrid
.. image:: https://github.com/mrcagney/geohexgrid/actions/workflows/test.yml/badge.svg :target: https://github.com/mrcagney/geohexgrid/actions/workflows/test.yml
A tiny Python 3.10+ library for making geographic flat-top hexagonal grids like QGIS's create grid function <https://docs.qgis.org/3.22/en/docs/user_manual/processing_algs/qgis/vectorcreation.html?highlight=create%20grid#create-grid>
.
That's it.
Not designed for making other kinds of grids or discrete global grid systems <https://en.wikipedia.org/wiki/Discrete_global_grid>
.
Here a hexagonal grid, or hex grid for short, is a finite subset of a hexagonal tiling.
A hexagonal tiling is a covering of the plane with regular hexagons in which exactly three hexagons meet at each vertex.
(For more details, see the Wikipedia article on hexagonal tilings <https://en.wikipedia.org/wiki/Hexagonal_tiling>
_.)
The circumradius of a hex grid is the circumradius of any one of its hexagons, that is, the radius of a circle circumscribing any one of the hexagons.
This library favours the word 'grid' over 'tiling', because 'grid' is used more often in geographic context, the main context of this library.
The two main features of this library are
The main non-feature of this library is
Here's a typical example.
.. code-block:: python
import geopandas as gpd import geohexgrid as ghg
nz = gpd.read_file(DATA_DIR / "nz_tas.gpkg")
grid = ghg.make_grid_from_gdf(nz, R=10_000)
base = nz.plot(color="black", figsize=(10, 10), aspect="equal") grid.plot(ax=base, color="white", edgecolor="red", alpha=0.5)
.. image:: nz_10000m.png :width: 400 :alt: hexagon grid of 10,000-metre circumradius covering New Zealand
But why hexagons?!
Because hexagons are the bestagons <https://www.youtube.com/watch?v=thOifuHs6eY>
_.
More seriously, no one grid type works best for all geographic applications.
MRCagney, this library's funder, often works with isochrones, which favour simple convex equal area grids with equidistant neighbour cells, that is, hex grids.
Install from PyPI, e.g. via uv add geohexgrid
.
See the Marimo notebook at notebooks/examples.py
.
MRCagney <https://mrcagney.com>
_ for periodically funding this project.great write up of hexagonal grids <https://www.redblobgames.com/grids/hexagons>
_ for computer games.main.make_grid_from_gdf
with trim_mode
option.main.make_grid_from_gdf
when using a trim mode.main.py
.
This was preventing users from installing Geohexgrid, because Loguru is only a development dependency.make_grid_from_bounds
in response to Issue 2 <https://github.com/mrcagney/geohexgrid/issues/2>
_.grid_from_gdf
.clip
option to the function grid_from_gdf
.FAQs
A Python library for making geographic flat-top hexagon grids like QGIS's `create grid` function
We found that geohexgrid demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.