
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
A Python library for making geographic flat-top hexagon grids like QGIS's `create grid` function
Geohexgrid
A tiny Python 3.9+ 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 Jupyter notebook at notebooks/examples.ipynb
.
MRCagney <https://mrcagney.com>
_ for periodically funding this project.great write up of hexagonal grids <https://www.redblobgames.com/grids/hexagons>
_ for computer games.make_grid_from_bounds
in response to Issue 1 <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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.