stilt.Mesh#

class stilt.Mesh(*, ids: tuple[str, ...], geometries: tuple[Any, ...], crs: str = '+proj=longlat') → None[source]#

Arbitrary polygon cells with ids: the general state geometry.

Parameters

idssequence of str

Unique label per cell; becomes the state index (index).

geometriessequence of shapely Polygon / MultiPolygon

One polygon per id, in crs coordinates.

crsstr

PROJ string or "EPSG:xxxx" of the polygon coordinates.

Methods#

from_file(path[, ids])

Build from a shapefile / GeoPackage / GeoJSON via geopandas.

from_geodataframe(gdf[, ids])

Build from a GeoDataFrame (polygons in its active geometry column).

from_grid(grid)

Every cell of a rectilinear grid as a polygon, in grid.index order.

from_h3(resolution, bounds)

H3 hexagons of resolution covering bounds (requires h3).

from_windows(coords, size, *[, ids, crs])

Rectangular windows centred on points, e.g. named point sources.

to_crs(crs)

Return this mesh reprojected to crs (requires pyproj).

Attributes#

bounds

(xmin, ymin, xmax, ymax) envelope of all cells.

hash

10-char SHA-256 of ids, WKB geometries and CRS.

index

the cell ids, named "cell".

is_longlat

True when polygon coordinates are lon/lat degrees.

min_cell_width

Smallest cell envelope side, in crs units (sets raster resolution).

ids

geometries

crs