brails.scrapers.nsi_parser.nsi_parser module
This module defines a class for scraping data from NSI.
A class for interacting with the National Structural Inventory (NSI) data. |
- class brails.scrapers.nsi_parser.nsi_parser.NSI_Parser
Bases:
object
A class for interacting with the National Structural Inventory (NSI) data.
This class provides methods for fetching and processing NSI data, including mapping the data to building footprints, extracting relevant attributes, and generating inventory outputs in formats compatible with BRAILS and other GIS applications.
Key responsibilities of this class include: - Fetching NSI data for given bounding box coordinates. - Mapping NSI points to corresponding footprints. - Converting NSI attributes to BRAILS-compatible attributes. - Optionally retrieving extended features (such as split levels and
basement information).
Generating and formatting the processed data in GeoJSON format for further analysis.
- Attributes:
- attributes (dict):
Stores the processed attributes for each footprint, including location, building characteristics, and extended features.
- brails2r2dmap (dict):
A mapping between NSI attributes and their corresponding BRAILS attributes.
- footprints (dict):
Stores the footprint data.
- nsi2brailsmap (dict):
A mapping between NSI attribute keys and their corresponding BRAILS attributes.
- GetNSIData(footprints: list, lengthUnit: str = 'ft', outfile: str = '', get_extended_features: bool = False, add_features: list = [])
Match NSI buildings points to a set of footprints.
Method that reads NSI buildings points and matches the data to a set of footprints and writes the data in a BRAILS-compatible format
- Args:
- footprints: List of footprint data defined as a list of lists of
coordinates in EPSG 4326, i.e., [[vert1],….[vertlast]]. Vertices are defined in [longitude,latitude] fashion.
lengthUnit: The units for the data to be returned in, ‘m’ or ‘ft’
- outfile: string containing the name of the output file
Currently, only GeoJSON format is supported
get_extended_features: additionally get split level and gararge
add_features: list of features to be included
- Output:
- dict: Attribute dictionary for the footprints containing the
attributes: 1)latitude, 2)longitude, 3)building plan area, 4)number of floors, 5)year of construction, 6)replacement cost, 7)structure type, 8)occupancy class, 9)footprint polygon If “get_extended_features” option is selected, output additionally includes 10) split level and 11) gararge
- get_filtered_data_given_inventory(inventory: AssetInventory, length_unit: str = 'ft', outfile: str = '', get_extended_features: bool = False, add_features: list = [])
Get NSI data corresponding to an AssetInventory.
- Input: RegionBoundary
The region boundary
- length unit
The units data to be returned in, ‘m’ or ‘ft’
- outfile
Optional string
- get_extended_features
additionally get split level and gararge
- add_features
Optional list of strings. Use this if you want to include additional features in the filtered inventory
- Output: dict
Attribute dictionary for the footprints containing the attributes: 1)latitude, 2)longitude, 3)building plan area, 4)number of floors, 5)year of construction, 6)replacement cost, 7)structure type, 8)occupancy class, 9)footprint polygon If “get_extended_features” option is selected, output additionally includes 10) split level and 11) gararge
- get_raw_data(region: RegionBoundary) AssetInventory
Retrieve raw NSI data for a specified region.
- Args:
- region (RegionBoundary):
The region boundary object defining the area of interest.
- Returns:
- AssetInventory:
An AssetInventory object containing assets (buildings) within the given region, extracted from the NSI data.
- Notes:
The function retrieves NSI data within the bounding box of the provided region boundary, filters out points outside the boundary, and returns the resulting data in an AssetInventory.
The length unit for the data is assumed to be in meters (‘m’) or feet (‘ft’) as specified in the class initialization, but the function currently does not modify the length unit in this method.
- Example:
region = RegionBoundary(…) inventory = get_raw_data(region)