NsiBuildings(gpkg_file: str, layer_name: str = 'nsi', overrides: Dict[str, str] | None = None)
Bases: Buildings
NSI (National Structure Inventory) buildings class with geopackage loading and preprocessing.
Source code in packages/core/src/sphere/core/schemas/nsi_buildings.py
| def __init__(self, gpkg_file: str, layer_name: str = "nsi", overrides: Dict[str, str] | None = None):
# If gpkg_file does not have a drive letter, assume relative to cwd.
drive, _ = os.path.splitdrive(gpkg_file)
if not drive:
gpkg_path = os.path.join(os.getcwd(), gpkg_file)
else:
gpkg_path = gpkg_file
# Load the GeoDataFrame from the GeoPackage file
try:
gdf = gpd.read_file(gpkg_path, layer=layer_name)
self._preprocess_gdf(gdf)
except Exception as e:
raise ValueError(f"Failed to load GeoPackage: {str(e)}")
# Initialize the parent class with the loaded and preprocessed GeoDataFrame
super().__init__(gdf, overrides)
|