<<<<<<< HEAD
This repository contains scripts for downloading, processing, and analyzing fire risk data, specifically focused on the Marshall Fire case study. The workflow includes downloading satellite imagery, reprojecting TIFF files, obtaining building footprints from OpenStreetMap, calculating building centroids, generating input images for DamageMap, running damage prediction inference, and combining predictions with manual observations.
- R (for downloading TIFFs)
- Python 3 with the following packages:
osgeo(gdal,osr)requestsshapelytqdmijson(optional for large GeoJSONs)numpy,pandas,Pillow,matplotlib,torch,torchvision
Install Python dependencies using:
pip install gdal requests shapely tqdm ijson numpy pandas pillow matplotlib torch torchvision/MarshallFire/
│
├─ DATA/
│ ├─ MaxarFileList.csv # CSV file with TIFF URLs
│ ├─ maxr_tifs/ # Raw downloaded TIFFs
│ ├─ maxr_tifs_good/ # Cleaned/verified TIFFs
│ ├─ reprojected_tifs/ # TIFFs reprojected to EPSG:4326
│ ├─ building_footprints/ # Building footprints from OSM
│ ├─ building_Centroids/ # Centroids of building footprints
│ ├─ centroid_address_results/ # CSVs with building addresses
│ ├─ images/ # Input image patches for DamageMap
│ ├─ images/all_predictions_csvs/ # CSVs from DamageMap inference
│ └─ merged_labels.csv # Final merged predictions
│
├─ Download_tifs_1.R # Download TIFFs from URLs
├─ reproject_tifs_1.5.py # Reproject TIFFs to EPSG:4326
├─ GetBuildingFootprints_2.py # Extract building footprints from fire perimeter
├─ FindCentroidOfStructures_3.py # Compute centroids of building footprints
├─ create_input_images_5_multipleTiffs.py # Generate image patches for DamageMap
├─ runningDamageMap_6.py # Run DamageMap inference on images
├─ create_prediction_csv_7.py # Aggregate DamageMap predictions
└─ combines_predictions_with_observation_csv_8.py # Merge predictions with manual labels
File: Download_tifs_1.R
Purpose: Downloads Maxar satellite TIFF files for a specified date from a CSV file of URLs.
File: reproject_tifs_1.5.py
Purpose: Reprojects TIFFs to EPSG:4326, skipping files already in target projection.
File: GetBuildingFootprints_2.py
Purpose: Fetches building footprints from the Ohsome API within fire perimeters.
File: FindCentroidOfStructures_3.py
Purpose: Computes centroids of building footprints for address extraction or image cropping.
File: create_input_images_5_multipleTiffs.py
Purpose: Generates image patches centered on building coordinates from reprojected TIFFs. Patches are filtered for brightness and saved for DamageMap inference.
File: runningDamageMap_6.py
Purpose: Runs batch inference using the DamageMap model on input image patches, generating CSVs and PDF reports of predictions.
Files:
create_prediction_csv_7.py: Aggregates predictions from multiple DamageMap CSVs and computes mean prediction per building.combines_predictions_with_observation_csv_8.py: Merges model predictions with manual labels into a final CSV.
flowchart TD
A[Download TIFFs] --> B[Reproject TIFFs]
B --> C[Get Building Footprints]
C --> D[Find Centroids of Structures]
D --> E[Create Input Images for DamageMap]
E --> F[Run DamageMap]
F --> G[Aggregate Predictions]
G --> H[Merge with Manual Labels]
- Download TIFFs:
Download_tifs_1.R - Reproject TIFFs:
reproject_tifs_1.5.py - Extract Building Footprints:
GetBuildingFootprints_2.py - Compute Centroids:
FindCentroidOfStructures_3.py - Generate Input Images:
create_input_images_5_multipleTiffs.py - Run DamageMap Inference:
runningDamageMap_6.py - Aggregate Predictions:
create_prediction_csv_7.py - Merge with Manual Labels:
combines_predictions_with_observation_csv_8.py
- Adjust paths and
fire_namevariable in each script to match your local directory structure. - Respect API rate limits for Ohsome when processing many files.
- Large TIFFs and images may require substantial memory and disk space.
- The interactive labeler in
create_prediction_csv_7.pyallows manual correction of DamageMap predictions.
engine-vulnerability-2/main