brails.scrapers.usgs_data_scrapers.nlcd_scraper module
Module for scraping and processing USGS NLCD land cover data.
|
Scraper for USGS NLCD land cover data. |
- class brails.scrapers.usgs_data_scrapers.nlcd_scraper.NLCDScraper(input_dict=None)
Bases:
AssetDataAugmenter
Scraper for USGS NLCD land cover data.
This class downloads tiled NLCD rasters from USGS WMS services, mosaics them in memory, and assigns NLCD land cover classes to each asset in an asset inventory based on its geographic location.
- populate_feature(input_inventory)
Scrape NLCD land cover values for each asset in the inventory.
Each asset’s centroid is sampled against an in-memory NLCD raster mosaic. The resulting fine-grained NLCD class is stored in the asset’s
'land_cover'
field.- Parameters:
input_inventory (AssetInventory) – The inventory of assets with location information.
- Returns:
The same inventory with each asset updated to include a
'land_cover'
feature.- Return type:
Example
>>> from brails import Importer >>> from brails.types.asset_inventory import AssetInventory >>> >>> # Initialize the scraper >>> importer = Importer() >>> scraper = importer.get_class('NLCDScraper')() >>> >>> # Load or create an asset inventory >>> inventory = AssetInventory() >>> asset1 = Asset(1, [[-81.379, 28.538]]) >>> asset2 = Asset(2, [[-81.463, 28.713]]) >>> _ = inventory.add_asset(1, asset1) >>> _ = inventory.add_asset(2, asset2) >>> >>> # Populate land cover features >>> updated_inventory = scraper.populate_feature(inventory) >>> >>> # Access the assigned land cover >>> updated_inventory.inventory["1"].features["land_cover"] 'Developed, Medium Intensity'