Skip to main content
Public Preview
The following content is a read-only preview of an executable Jupyter notebook.To run this notebook interactively:
  1. Go to Wherobots Cloud.
  2. Start a runtime.
  3. Open the notebook.
  4. In the Jupyter Launcher:
    1. Click File > Open Path.
    2. Paste the following path to access this notebook: examples/Analyzing_Data/RasterFlow_ChangeDetection.ipynb
    3. Click Enter.
This notebook finds where land changed between two years, using Google’s AlphaEarth Foundations (AEF) embeddings1 and RasterFlow’s run_mosaics_change task. It needs no training data or labels. AEF summarizes a year of satellite observations as a 64-dimensional embedding for every 10 m pixel. If a pixel’s embedding in one year is far from its embedding in an earlier year, something there changed. Because the embeddings are precomputed, scoring change over a large area is fast and cheap. That makes it a good first pass: find the small areas that changed, then run slower, more resource-intensive analysis, such as building footprints or an object detection model, only on those areas to work out what kind of change happened. This notebook follows that pattern. The notebook:
  1. Runs run_mosaics_change on the public global AEF mosaic for an area and two years, scoring each pixel by the distance between its two embeddings, and maps the scores.
  2. Turns the pixels with the most change into polygons with vectorize_mosaic.
  3. Joins the change polygons with Overture Maps building footprints in WherobotsDB, to tell new neighborhoods apart from other change.
  4. Optionally, detects the roofs in the new neighborhood with SAM3 on 30 cm aerial imagery from after the change, and compares them with Overture.
Related reading: AlphaEarth Foundations for agriculture change detection and AlphaEarth Foundations change detection, part 2.

Choose an area and two years

The area is north of Denham Springs, Louisiana, where a new subdivision on Joe Lynn Trails was built between 2021 and 2023. The NAIP 30 cm aerial photos of the area show it: on 19 November 2021 the land was graded and the streets were laid out, with no houses yet; by 3 May 2023 the subdivision was complete. You can check the results against these photos: open the 2021 photo and the 2023 photo of the whole area, from Microsoft’s Planetary Computer. NAIP aerial photos of the Joe Lynn Trails site: graded land and laid-out streets on 19 November 2021, and the finished subdivision on 3 May 2023 Imagery: USDA NAIP, from Microsoft’s Planetary Computer. The task reads only the part of the global AEF mosaic that covers this polygon.

Using the Wherobots Tasks API

Each RasterFlow step runs as a task through the Wherobots Python SDK. wb.tasks.run_and_wait starts the task, waits for it to finish, and raises an error if it fails. .output gives the URI for a single-output task. For SAM3, read the predictions from results.

Score the change between the two years

run_mosaics_change reads the global AEF mosaic on Source Cooperative directly, so there’s no mosaic to build first. The inputs:
  • mosaic_uri and data_var: the public AEF Zarr store and its embeddings array.
  • distance_metric: alpha_earth_cosine_distance converts AEF’s quantized int8 values back to unit vectors before taking the cosine distance. Use it for AEF; use cosine_distance for embeddings that aren’t stored this way.
  • score_methods: difference compares each selected year with the previous selected year, here 2023 with 2021.
  • time_selection: the two years to compare.
  • robust_time_zscore: false keeps raw distances, which run from 0 (unchanged) to 2. The z-score option rescales each pixel by its own variation over time, which is noisy with only a few annual samples.
This should take about 10 minutes to complete.

Look at the change scores

The output is a Zarr store on the AEF grid, with one band, difference_alpha_earth_cosine_distance, and one time step per selected year. The first year has no earlier year to compare with, so it’s empty; the map below shows the second, the 2021-to-2023 scores.
In a test run, the map looks like this: AEF change scores from 0.1 to 0.5 around the Joe Lynn Trails subdivision on a satellite basemap Most of the area scores under 0.1, so the map leaves it clear. The bright patch in the middle is the new subdivision, at 0.3 to 0.45. This notebook calls a score above 0.2 “changed”: that keeps the subdivision as one polygon, while 0.3 breaks it into fragments and 0.1 also takes in the fields and trees around it.

Turn the largest changes into polygons

vectorize_mosaic keeps the pixels whose score is above threshold, joins neighboring pixels into polygons, and with stats=True records the mean and standard deviation of the scores inside each polygon.

Find the new buildings with WherobotsDB

A change score says where the embeddings changed, not what changed. Joining the change polygons with building footprints from Overture Maps, available in Wherobots Open Data, separates new neighborhoods from other change, such as land cleared for a later phase. The query keeps change polygons of at least 1 hectare and, for each, counts the buildings whose center falls inside it and sums their footprint area.
The polygon with the most buildings is the new subdivision: in a test run, a 5.9 ha change polygon containing 79 buildings with a median footprint of 214 m². The other two polygons are under 2 ha and contain no buildings; they mark change other than new houses, such as land being cleared.

Map the changes and the new buildings

Show the change scores, the change polygons and the Overture buildings inside them on a satellite basemap.

Optional: detect the roofs in the 2023 aerial imagery with SAM3

Overture’s footprints come from a recent release, so they can include buildings finished after 2023. To count the roofs that were there in 2023, you can run SAM3 with the prompt "roofs" on the 30 cm NAIP imagery from 2023, flown here on 3 May 2023. The predict_mosaic_geometries_recipe task builds the imagery mosaic and runs the model over the bounding box of the change polygon. It adds about 15 minutes of GPU time, so it’s off by default. This is the result of a previous run, on the 2021 and 2023 NAIP imagery: SAM3 roofs and the AEF change polygon on NAIP imagery from 2021 and 2023 SAM3 found 80 roofs of at least 50 m² inside the change polygon, with a median of 265 m², against Overture’s 79 buildings with a median of 214 m². Every SAM3 roof overlaps an Overture building and every Overture building overlaps a SAM3 roof, so the subdivision was complete when the 2023 imagery was flown and Overture hasn’t added later buildings here. The differences are small:
  • One extra roof: one Overture building is covered by two SAM3 polygons. SAM3 works on 1,008-pixel image tiles and doesn’t merge polygons across them, so a roof on a tile edge can be counted twice.
  • Larger footprints: SAM3 outlines the roof as seen from above, including the eaves, while Overture footprints usually follow the walls.
To run it yourself, set run_sam3 = True.

Next steps

  • Other objects: change SAM3’s text_prompt, for example to ["swimming pools", "solar panels"]. See the SAM3 notebook for checking 30 cm NAIP coverage before you run it elsewhere.
  • Compare before and after imagery yourself: build NAIP mosaics for 2021 and 2023 over the change polygons with the build_mosaics task (see the NAIP mosaic notebook).
  • Other places and years: change aoi and years. AEF covers 2017 to 2025 globally.
  • Unusual years in a longer series: select more years and add loo_medoid to score_methods. It compares each year with the most typical of the other years, so one-off events stand out; see the part 2 blog post.

References

  1. Brown, C. F., Kazmierski, M. R., Pasquarella, V. J., et al. (2025). AlphaEarth Foundations: An embedding field model for accurate and efficient global mapping from sparse label data. arXiv preprint arXiv:2507.22291. The AlphaEarth Foundations Satellite Embedding dataset is produced by Google and Google DeepMind (CC BY 4.0); this notebook reads the Zarr mosaic of it published by Taylor Geospatial on Source Cooperative.