voxcity.geoprocessor.raster.landcover¶
Functions¶
|
Convert a land cover grid to a tree height grid. |
Create a land cover grid from a GeoTIFF file within a polygon boundary. |
|
|
Create a grid of land cover classes from GeoDataFrame polygon data. |
Module Contents¶
- voxcity.geoprocessor.raster.landcover.tree_height_grid_from_land_cover(land_cover_grid_ori: numpy.ndarray) numpy.ndarray[source]¶
Convert a land cover grid to a tree height grid.
Expects 1-based land cover indices where class 5 is Tree.
- voxcity.geoprocessor.raster.landcover.create_land_cover_grid_from_geotiff_polygon(tiff_path: str, mesh_size: float, land_cover_classes: Dict[str, Any], polygon: List[Tuple[float, float]]) numpy.ndarray[source]¶
Create a land cover grid from a GeoTIFF file within a polygon boundary.
Uses
compute_cell_center_coords()so rotated rectangles are handled correctly.
- voxcity.geoprocessor.raster.landcover.create_land_cover_grid_from_gdf_polygon(gdf, meshsize: float, source: str, rectangle_vertices: List[Tuple[float, float]], default_class: str = 'Developed space', detect_ocean: bool = True, land_polygon='NOT_PROVIDED') numpy.ndarray[source]¶
Create a grid of land cover classes from GeoDataFrame polygon data.
Uses vectorized rasterization for ~100x speedup over cell-by-cell intersection. Correctly handles rotated rectangles by rasterizing onto a bounding-box grid and then sampling at the rotated cell centre coordinates.
- Parameters:
gdf – GeoDataFrame with land cover polygons and ‘class’ column
meshsize – Grid cell size in meters
source – Land cover data source name (e.g., ‘OpenStreetMap’)
rectangle_vertices – List of (lon, lat) tuples defining the area
default_class – Default class for cells not covered by any polygon
detect_ocean – If True, use OSM land polygons to detect ocean areas. Areas outside land polygons will be classified as ‘Water’ instead of the default class.
land_polygon – Optional pre-computed land polygon from OSM coastlines. If provided (including None), this is used directly. If “NOT_PROVIDED”, coastlines will be queried when detect_ocean=True.
- Returns:
2D numpy array of land cover class names