Skip to content

Innosphere-Bridger/engine-vulnerability

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

<<<<<<< HEAD

engine-vulnerability

Colorado-Wyoming Engine repo for all the scripts

Fire Risk Data Processing Pipeline

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.


Table of Contents

  1. Requirements
  2. Directory Structure
  3. Scripts
  4. Workflow Diagram
  5. Usage
  6. Notes

Requirements

  • R (for downloading TIFFs)
  • Python 3 with the following packages:
    • osgeo (gdal, osr)
    • requests
    • shapely
    • tqdm
    • ijson (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

Directory Structure

/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

Scripts

1. Download TIFFs

File: Download_tifs_1.R
Purpose: Downloads Maxar satellite TIFF files for a specified date from a CSV file of URLs.

2. Reproject TIFFs

File: reproject_tifs_1.5.py
Purpose: Reprojects TIFFs to EPSG:4326, skipping files already in target projection.

3. Get Building Footprints

File: GetBuildingFootprints_2.py
Purpose: Fetches building footprints from the Ohsome API within fire perimeters.

4. Find Centroids of Structures

File: FindCentroidOfStructures_3.py
Purpose: Computes centroids of building footprints for address extraction or image cropping.

5. Create Input Images

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.

6. Run DamageMap

File: runningDamageMap_6.py
Purpose: Runs batch inference using the DamageMap model on input image patches, generating CSVs and PDF reports of predictions.

7. Combine 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.

Workflow Diagram

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]
Loading

Usage Workflow

  1. Download TIFFs: Download_tifs_1.R
  2. Reproject TIFFs: reproject_tifs_1.5.py
  3. Extract Building Footprints: GetBuildingFootprints_2.py
  4. Compute Centroids: FindCentroidOfStructures_3.py
  5. Generate Input Images: create_input_images_5_multipleTiffs.py
  6. Run DamageMap Inference: runningDamageMap_6.py
  7. Aggregate Predictions: create_prediction_csv_7.py
  8. Merge with Manual Labels: combines_predictions_with_observation_csv_8.py

Notes

  • Adjust paths and fire_name variable 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.py allows manual correction of DamageMap predictions.

engine-vulnerability-2/main

About

Colorado-Wyoming Engine repo for all the scripts

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 99.3%
  • R 0.7%