voxcity.utils.zoningยถ

Lon/lat polygon utilities for VoxCity grids.

Bridges geographic polygons (closed lon/lat rings, GeoJSON-style) into the gridโ€™s (i, j) cell frame. Algorithm: project every cell centre to lon/lat via GridProjector, then test point-in-polygon with MplPath.

Functionsยถ

mask_from_lonlat_ring(โ†’ numpy.ndarray)

Rasterize a closed lon/lat ring to a (nx, ny) boolean mask.

polygon_lonlat_to_cells(โ†’ List[Tuple[int, int]])

Rasterize a lon/lat ring to a list of (i, j) cell indices.

points_in_polygon_lonlat(โ†’ numpy.ndarray)

Vectorized point-in-polygon test (boolean array of length N).

Module Contentsยถ

voxcity.utils.zoning.mask_from_lonlat_ring(ring: Sequence[Sequence[float]], grid_geom: voxcity.utils.projector.GridGeom) numpy.ndarray[source]ยถ

Rasterize a closed lon/lat ring to a (nx, ny) boolean mask.

A cell is True iff its centre lies inside the polygon.

voxcity.utils.zoning.polygon_lonlat_to_cells(ring: Sequence[Sequence[float]], grid_geom: voxcity.utils.projector.GridGeom) List[Tuple[int, int]][source]ยถ

Rasterize a lon/lat ring to a list of (i, j) cell indices.

Equivalent to np.argwhere(mask_from_lonlat_ring(...)) returned as a list of Python tuples. Provided for parity with the helper that has historically lived in app/backend/zoning.py; new code should prefer mask_from_lonlat_ring.

voxcity.utils.zoning.points_in_polygon_lonlat(points_lonlat: numpy.ndarray, ring: Sequence[Sequence[float]]) numpy.ndarray[source]ยถ

Vectorized point-in-polygon test (boolean array of length N).