h3_grid
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:
>>> from histolytics.spatial_ops.h3 import h3_grid
>>> from histolytics.data import cervix_tissue
>>>
>>> # get the stromal tissue
>>> tis = cervix_tissue()
>>> stroma = tis[tis["class_name"] == "stroma"]
>>> # Fit an H3 grid to the stromal tissue
>>> h3_gr = h3_grid(stroma, resolution=9)
>>> print(h3_gr.head(3))
geometry
8982a939503ffff POLYGON ((6672.79721 859.08743, 6647.90711 661...
8982a939877ffff POLYGON ((2556.61731 5658.46273, 2581.53692 58...
8982a939c4bffff POLYGON ((4546.44516 4059.58249, 4366.53531 39...
>>> ax = tis.plot(column="class_name", figsize=(5, 5), aspect=1, alpha=0.5)
>>> h3_gr.plot(ax=ax, edgecolor="black", facecolor="none", lw=1)
>>> ax.set_axis_off()