The Analyzer
The Prefire Defensible Space Analyzer combines interactive mapping, satellite imagery, and a property questionnaire (coming soon) to estimate how well a home's surroundings comply with various fire-safe regulations.
What It Does
Prefire gives homeowners a free, self-service way to assess their property's wildfire risk. Users navigate to their property on a satellite map, draw polygons around their structures, and complete a short questionnaire about their site conditions. That data is fed into a model that estimates defensible space compliance and produces a personalized report with actionable recommendations. How the score is calculated →
The ML Pipeline
When you submit your drawn polygon, it triggers an inference pipeline running on AWS Lambda. The stages run in sequence:
- Tree crown detection — two detectors run in parallel: DeepForest, an object detection model trained on aerial RGB imagery, and an NDVI + watershed segmentation approach using the near-infrared band from NAIP imagery. Detections from both are merged and deduplicated by overlap ratio.
- Mask refinement — each surviving detection is passed to SAM 2 (Segment Anything Model 2), which replaces the rough bounding box with a precise pixel-level crown mask.
- Slope extraction — a slope raster is derived from USGS 3DEP elevation data. The slope at each crown's centroid determines which CAL FIRE horizontal spacing rule applies to that tree.
- Zone analysis — each crown is compared against the defensible space zone buffers computed from your drawn structure polygon. Trees touching the structure or violating spacing requirements are flagged.
- Risk scoring — flagged crowns, questionnaire answers, and your property's Wildfire Hazard Potential (WHP) class are combined into a final score. How the score is calculated →
The Mapping Layer
The map is built on Leaflet, an open-source JavaScript mapping library.
County boundaries are fetched in real time from the U.S. Census TIGERweb API and rendered as a GeoJSON overlay to help users orient themselves within their county.
Building Footprint Overlay
An optional building footprints layer is served as PMTiles from Amazon S3 — shows known structure outlines on the map. This helps users accurately place their polygons without having to eyeball structure edges from satellite imagery alone. PMTiles is a cloud-native tile format that allows efficient, range-request-based delivery of vector tiles without a tile server.
Tech Stack
- Frontend: React + TypeScript, built with Vite, styled with Tailwind CSS
- Mapping: Leaflet, Leaflet Draw, Protomaps Leaflet for PMTiles rendering
- Data delivery: PMTiles hosted on Amazon S3
- Hosting: Static site deployed to Amazon S3 + CloudFront CDN with pre-rendered HTML for SEO
- Backend: Python on AWS Lambda — separate functions for geocoding, inference, scoring, and job management
- ML models: DeepForest (tree detection), NDVI + watershed segmentation, SAM 2 (mask refinement)
- Imagery: NAIP aerial imagery (USDA), 3DEP elevation data (USGS)
- Address search: Nominatim geocoding API