voxcity.geoprocessor ==================== .. py:module:: voxcity.geoprocessor Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/voxcity/geoprocessor/conversion/index /autoapi/voxcity/geoprocessor/draw/index /autoapi/voxcity/geoprocessor/heights/index /autoapi/voxcity/geoprocessor/io/index /autoapi/voxcity/geoprocessor/merge_utils/index /autoapi/voxcity/geoprocessor/mesh/index /autoapi/voxcity/geoprocessor/network/index /autoapi/voxcity/geoprocessor/overlap/index /autoapi/voxcity/geoprocessor/raster/index /autoapi/voxcity/geoprocessor/selection/index /autoapi/voxcity/geoprocessor/surface_meta/index /autoapi/voxcity/geoprocessor/utils/index Attributes ---------- .. autoapisummary:: voxcity.geoprocessor.SELECTABLE_KINDS Functions --------- .. autoapisummary:: voxcity.geoprocessor.filter_and_convert_gdf_to_geojson voxcity.geoprocessor.geojson_to_gdf voxcity.geoprocessor.gdf_to_geojson_dicts voxcity.geoprocessor.get_gdf_from_gpkg voxcity.geoprocessor.load_gdf_from_multiple_gz voxcity.geoprocessor.extract_building_heights_from_gdf voxcity.geoprocessor.extract_building_heights_from_geotiff voxcity.geoprocessor.complement_building_heights_from_gdf voxcity.geoprocessor.filter_buildings voxcity.geoprocessor.find_building_containing_point voxcity.geoprocessor.get_buildings_in_drawn_polygon voxcity.geoprocessor.process_building_footprints_by_overlap voxcity.geoprocessor.merge_gdfs_with_id_conflict_resolution voxcity.geoprocessor.attach_surface_face_meta voxcity.geoprocessor.compute_face_areas voxcity.geoprocessor.surface_zone_mask voxcity.geoprocessor.classify_surface_faces voxcity.geoprocessor.make_surface_face_key voxcity.geoprocessor.classify_surface_kind voxcity.geoprocessor.wall_orientation Package Contents ---------------- .. py:function:: filter_and_convert_gdf_to_geojson(gdf, rectangle_vertices) Filter a GeoDataFrame by a bounding rectangle and convert to GeoJSON format. This function performs spatial filtering on a GeoDataFrame using a bounding rectangle, and converts the filtered data to GeoJSON format. It handles both Polygon and MultiPolygon geometries, splitting MultiPolygons into separate Polygon features. :param gdf: Input GeoDataFrame containing building data Must have 'geometry' and 'height' columns Any CRS is accepted, will be converted to WGS84 if needed :type gdf: GeoDataFrame :param rectangle_vertices: List of (lon, lat) tuples defining the bounding rectangle Must be in WGS84 (EPSG:4326) coordinate system Must form a valid rectangle (4 vertices, clockwise or counterclockwise) :type rectangle_vertices: list :returns: List of GeoJSON features within the bounding rectangle Each feature contains: - geometry: Polygon coordinates in WGS84 - properties: Dictionary with 'height', 'confidence', and 'id' - type: Always "Feature" :rtype: list Memory Optimization: - Uses spatial indexing for efficient filtering - Downcasts numeric columns to save memory - Cleans up intermediate data structures - Splits MultiPolygons into separate features .. py:function:: geojson_to_gdf(geojson_data, id_col='id') Convert a list of GeoJSON-like dict features into a GeoDataFrame. This function takes a list of GeoJSON feature dictionaries (Fiona-like format) and converts them into a GeoDataFrame, handling geometry conversion and property extraction. It ensures each feature has a unique identifier. .. py:function:: gdf_to_geojson_dicts(gdf, id_col='id') Convert a GeoDataFrame to a list of dicts similar to GeoJSON features. .. py:function:: get_gdf_from_gpkg(gpkg_path, rectangle_vertices) Read a GeoPackage file and convert it to a GeoDataFrame with consistent CRS. Note: rectangle_vertices is currently unused but kept for signature compatibility. .. py:function:: load_gdf_from_multiple_gz(file_paths) Load GeoJSON features from multiple gzipped files into a single GeoDataFrame. Each line in each file must be a single GeoJSON Feature. .. py:function:: extract_building_heights_from_gdf(gdf_0: geopandas.GeoDataFrame, gdf_1: geopandas.GeoDataFrame) -> geopandas.GeoDataFrame Extract building heights from one GeoDataFrame and apply them to another based on spatial overlap. .. py:function:: extract_building_heights_from_geotiff(geotiff_path, gdf) Extract building heights from a GeoTIFF raster for building footprints in a GeoDataFrame. .. py:function:: complement_building_heights_from_gdf(gdf_0, gdf_1, primary_id='id', ref_id='id') Vectorized approach with GeoPandas to compute weighted heights and add non-intersecting buildings. Returns a single combined GeoDataFrame. .. py:function:: filter_buildings(geojson_data, plotting_box) Filter building features that intersect with a given bounding box. .. py:function:: find_building_containing_point(building_gdf, target_point) Find building IDs that contain a given point in their footprint. .. py:function:: get_buildings_in_drawn_polygon(building_gdf, drawn_polygons, operation='within') Find buildings that intersect with or are contained within user-drawn polygons. .. py:function:: process_building_footprints_by_overlap(filtered_gdf, overlap_threshold=0.5) Merge overlapping buildings based on area overlap ratio, assigning the ID of the larger building to smaller overlapping ones. .. py:function:: merge_gdfs_with_id_conflict_resolution(gdf_1, gdf_2, id_columns=['id', 'building_id']) Merge two GeoDataFrames while resolving ID conflicts by modifying IDs in the second GeoDataFrame. .. py:function:: attach_surface_face_meta(mesh: Any, reference_mesh: Any = None) -> Any Attach surface face metadata to a mesh in-place. Idempotent — safe to call multiple times. If reference_mesh is provided and has matching face topology, copy its keys directly. Stores mesh.metadata["surface_face_meta"] as list of dicts and version 1. .. py:function:: compute_face_areas(mesh: Any) -> numpy.ndarray Return the area of each triangular face of mesh as a float32 array. Assumes triangular faces (mesh.faces shape (n_faces, 3)). Voxcity's create_voxel_mesh produces triangulated output, so this fits the existing pipeline. If a future mesh source produces quads, triangulate first. .. py:function:: surface_zone_mask(face_meta: Sequence[Any], selectors: Sequence[Any]) -> numpy.ndarray Return a boolean mask of faces selected by the given selectors. Accepts both dict and object selectors, handles both snake_case and camelCase keys. Skips selectors with unknown/missing building_id gracefully. .. py:function:: classify_surface_faces(mesh: Any) -> list[dict] Classify each face of a mesh and return metadata dicts for each face. Returns a list of dicts with keys: face_key, building_id, surface_kind, orientation. .. py:function:: make_surface_face_key(building_id: int, centroid: Sequence[float], normal: Sequence[float], face_index: int) -> str Create a unique identifier for a surface face. .. py:function:: classify_surface_kind(normal: Sequence[float]) -> str Classify surface kind based on normal vector. .. py:function:: wall_orientation(normal: Sequence[float]) -> Optional[str] Determine wall orientation (N/E/S/W) from normal vector. .. py:data:: SELECTABLE_KINDS