hexgrid_overlay
cellseg_gsontools.grid.hexgrid_overlay(gdf, resolution=9, to_lonlat=True)
¶
Fit a h3
hexagonal grid on top of a geopandas.GeoDataFrame
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gdf |
GeoDataFrame
|
GeoDataFrame to fit grid to. |
required |
resolution |
int
|
H3 resolution, by default 9. |
9
|
to_lonlat |
bool
|
Whether to convert to lonlat coordinates, by default True. |
True
|
Returns:
Type | Description |
---|---|
GeoDataFrame
|
gpd.GeoDataFrame: Fitted h3 hex grid. |
Examples:
Fit a hexagonal grid to a gdf:
>>> from cellseg_gsontools import read_gdf
>>> from cellseg_gsontools.grid import hexgrid_overlay
>>> # Read in the tissue areas
>>> area_gdf = gpd.read_file("path/to/area.geojson")
>>> # Fit the grid
>>> hex_grid = hexgrid_overlay(area_gdf, resolution=9)
>>> hex_grid
gpd.GeoDataFrame