Skip to content

Add wildfire burn area detection example notebook#546

Open
Qandeel-01 wants to merge 2 commits into
opengeos:mainfrom
Qandeel-01:add-wildfire-burn-area-example
Open

Add wildfire burn area detection example notebook#546
Qandeel-01 wants to merge 2 commits into
opengeos:mainfrom
Qandeel-01:add-wildfire-burn-area-example

Conversation

@Qandeel-01

@Qandeel-01 Qandeel-01 commented Jul 15, 2026

Copy link
Copy Markdown

Description

Adds a new example notebook: docs/examples/wildfire_burn_area.ipynb

Demonstrates 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

  • Downloading post-fire satellite imagery via tms_to_geotiff()
  • Running SamGeo automatic mask generation with batch tiling (512×512 px chips)
  • Exporting detected burn polygons as GeoJSON and Shapefile
  • Interactive visualization with leafmap

Motivation

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.ipynb example.

Summary by CodeRabbit

  • Documentation
    • Added a step-by-step notebook demonstrating wildfire burn-area mapping from satellite imagery.
    • Covers imagery download, automated segmentation, mask visualization, and conversion of results to GeoJSON and Shapefile formats.
    • Includes interactive map visualization, styled polygon overlays, workflow summary, and references.

Qandeel-01 and others added 2 commits July 15, 2026 10:37
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.
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

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

Changes

Wildfire burn-area workflow

Layer / File(s) Summary
Study area and imagery setup
docs/examples/wildfire_burn_area.ipynb
Introduces the workflow, installs dependencies, creates a satellite map, defines a WGS84 bounding box, downloads post-fire imagery as a GeoTIFF, and verifies the imagery overlay.
Mask generation and vector export
docs/examples/wildfire_burn_area.ipynb
Initializes SamGeo, generates a tiled mask with the vit_h model, saves an annotated visualization, and exports GeoJSON and Shapefile outputs.
Results display and notebook metadata
docs/examples/wildfire_burn_area.ipynb
Overlays exported burn-area polygons with custom styling and adds workflow documentation, references, and Python notebook metadata.

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
Loading

Poem

A rabbit mapped the embered ground,
With orange lines the scars were found.
Tiles hopped through the smoky scene,
Masks bloomed bright in leafy green.
GeoJSON carrots joined the show—
A burrowed pipeline, set to go!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the new wildfire burn area example notebook.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8c2ccb7 and 6f44e44.

📒 Files selected for processing (1)
  • docs/examples/wildfire_burn_area.ipynb

Comment on lines +208 to +213
"sam.show_anns(\n",
" figsize=(14, 10),\n",
" axis=\"off\",\n",
" alpha=0.4,\n",
" output=\"campfire_annotated.png\",\n",
")"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Suggested change
"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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant