Add wildfire burn area detection example notebook#546
Conversation
Demonstrates SamGeo applied to post-fire satellite imagery using the 2018 Camp Fire (Paradise, CA) as a study area. Covers image download, automatic mask generation, vector export, and leafmap visualization.
for more information, see https://pre-commit.ci
📝 WalkthroughWalkthroughAdds a Jupyter notebook demonstrating wildfire burn-area detection with SamGeo: imagery download, tiled mask generation, raster visualization, GeoJSON and Shapefile export, and interactive polygon display for the Camp Fire study area. ChangesWildfire burn-area workflow
Estimated code review effort: 3 (Moderate) | ~15–30 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant leafmap
participant SATELLITE
participant SamGeo
participant VectorOutputs
User->>leafmap: Define Camp Fire bounding box
leafmap->>SATELLITE: Download post-fire imagery
SATELLITE-->>leafmap: Return GeoTIFF overlay
leafmap->>SamGeo: Provide downloaded imagery
SamGeo->>SamGeo: Generate tiled segmentation mask
SamGeo->>VectorOutputs: Export GeoJSON and Shapefile
VectorOutputs-->>leafmap: Display burn-area polygons
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/examples/wildfire_burn_area.ipynb`:
- Around line 208-213: Replace the incompatible sam.show_anns call with logic
that adds the batch-generated raster mask output to the interactive map m. Use
the generated tiled-mask file produced by sam.generate(batch=True), overlay it
on the source imagery, and preserve the intended annotation display without
relying on sam.image.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: d60ff858-2260-4ce1-bff5-7bbe658a440e
📒 Files selected for processing (1)
docs/examples/wildfire_burn_area.ipynb
| "sam.show_anns(\n", | ||
| " figsize=(14, 10),\n", | ||
| " axis=\"off\",\n", | ||
| " alpha=0.4,\n", | ||
| " output=\"campfire_annotated.png\",\n", | ||
| ")" |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
Fix show_anns compatibility with batch generation.
Because sam.generate() is called with batch=True, the model writes out tiled masks directly to disk but does not populate sam.image in memory. Consequently, the call to sam.show_anns() will immediately print "Please run generate() first." and return without displaying or saving any annotations.
To display the generated masks overlaid on the source imagery (as stated in the markdown cell above), add the generated raster mask directly to your interactive map m instead.
🐛 Proposed fix to use the interactive map
- "sam.show_anns(\n",
- " figsize=(14, 10),\n",
- " axis=\"off\",\n",
- " alpha=0.4,\n",
- " output=\"campfire_annotated.png\",\n",
- ")"
+ "m.add_raster(mask_path, layer_name=\"Generated Masks\", opacity=0.5, cmap=\"viridis\")\n",
+ "m"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "sam.show_anns(\n", | |
| " figsize=(14, 10),\n", | |
| " axis=\"off\",\n", | |
| " alpha=0.4,\n", | |
| " output=\"campfire_annotated.png\",\n", | |
| ")" | |
| "m.add_raster(mask_path, layer_name=\"Generated Masks\", opacity=0.5, cmap=\"viridis\")\n", | |
| "m" |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/examples/wildfire_burn_area.ipynb` around lines 208 - 213, Replace the
incompatible sam.show_anns call with logic that adds the batch-generated raster
mask output to the interactive map m. Use the generated tiled-mask file produced
by sam.generate(batch=True), overlay it on the source imagery, and preserve the
intended annotation display without relying on sam.image.
Description
Adds a new example notebook:
docs/examples/wildfire_burn_area.ipynbDemonstrates how to use SamGeo for wildfire burn area detection from post-fire satellite imagery, using the 2018 Camp Fire (Paradise, CA) as a study area.
What this notebook covers
tms_to_geotiff()SamGeoautomatic mask generation with batch tiling (512×512 px chips)leafmapMotivation
No wildfire-specific example currently exists in the docs. Wildfire burn area mapping is a common remote sensing use case in environmental monitoring, disaster response, and post-fire ecological assessment workflows. This notebook gives users a ready-to-run starting point for that domain.
Related
Follows the structure of the existing
satellite.ipynbexample.Summary by CodeRabbit