Skip to content

Change detection script#2

Open
tamara-glazer wants to merge 14 commits intomainfrom
change-detection
Open

Change detection script#2
tamara-glazer wants to merge 14 commits intomainfrom
change-detection

Conversation

@tamara-glazer
Copy link

@tamara-glazer tamara-glazer commented Nov 19, 2025

Adding a script to calculate volumentric change detection for a given threshold between two timestamps (e.g., 2020 -> 2025).

Example usage:
1.  Compare growth between two COGs:
    python compute-change-clusters.py
        --start-cog /path/or/url/to/2020q2.tif
        --end-cog /path/or/url/to/2025q2.tif
        --change-percentile 0.95
        --output-gpkg growth.gpkg
        --output-layer clusters
        --min-cluster-pixels 8 # optional

2.  Compare decline between two COGs:
    python compute-change-clusters.py
        --start-cog /path/or/url/to/2020q2.tif
        --end-cog /path/or/url/to/2025q2.tif
        --change-percentile -0.95
        --output-gpkg decline.gpkg
        --output-layer clusters
        --min-cluster-pixels 8 # optional

3.  Compare tifs stored in a blob container, limit analysis to bbox provided:
    Expected directory structure:
        predictions_root / timestamp / data_dir / tile_id.tif
    python compute-change-clusters.py
        --account-url https://<account>.blob.core.windows.net
        --container-name <container>
        --predictions-root predictions_root
        --data-dir data_dir
        --start-ts 2020q2
        --end-ts 2025q2
        --bbox -97.5 32.4 -96.3 33.2
        --change-percentile 0.95  # switch to negative for declines
        --output-gpkg growth.gpkg
        --output-layer clusters

Copy link
Member

@calebrob6 calebrob6 left a comment

Choose a reason for hiding this comment

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

High level comment -- did you double check to see if this works for decline clusters?
Other high level comment -- do you think a README section on change detection (or CHANGE_DETECTION.md) with an example screenshot output would be helpful? If so, we can definitely push this to later too.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new Python script to compute change detection clusters (growth or decline) between two temporal prediction rasters. The script calculates volumetric change (density × height) between two timestamps, applies a percentile-based threshold, vectorizes regions exceeding that threshold into polygons, and outputs results to a GeoPackage file.

Key changes:

  • New script for computing growth/decline clusters between two timestamps
  • Supports Azure Blob Storage access via SAS tokens for prediction tiles
  • Implements percentile-based thresholding for identifying significant changes
  • Vectorizes change clusters using 8-connected component labeling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tamara-glazer tamara-glazer force-pushed the change-detection branch 2 times, most recently from 6061690 to 31205b8 Compare February 2, 2026 23:12
@tamara-glazer
Copy link
Author

High level comment -- did you double check to see if this works for decline clusters? Other high level comment -- do you think a README section on change detection (or CHANGE_DETECTION.md) with an example screenshot output would be helpful? If so, we can definitely push this to later too.

Yes confirmed, and double checked that it works for "decline clusters"

@tamara-glazer
Copy link
Author

@calebrob6 Requesting a re-review. I added updates to the README with an example, and tested on the pre-processed COGs for Bamako. Ready to merge

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.

2 participants