Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Comparing two datasets side by side with a draggable slider

Why comparison matters

A large share of GeoAI work is fundamentally comparative: change detection compares two dates, model evaluation compares predictions against ground truth, and data selection compares imagery from different sensors or seasons. Viewing two layers stacked on top of each other, one at a time, makes it hard to judge fine spatial differences. A split view keeps both layers visible at the same extent and zoom level.


Core idea

A split-panel map places two layers side by side with a draggable divider, so both sides always share the same geographic extent and zoom, which keeps the comparison spatially honest.


Workflow

A. Prepare sample data

This example compares SWISSIMAGE imagery, a height raster and building footprints.

import geoai
import leafmap

swissimage_url = "https://data.source.coop/giuz/sds320/L03/data/willisau_2024_swissimage_rgb_subset.tif"
hag_url = "https://data.source.coop/giuz/sds320/L03/data/willisau_height_above_ground_ndsm.tif"
buildings_url = ("https://data.source.coop/giuz/sds320/L03/data/willisau_overture_buildings_subset.geojson")

swissimage_path = geoai.download_file(swissimage_url)
hag_path = geoai.download_file(hag_url)
buildings_path = geoai.download_file(buildings_url)

B. Build a basic split comparison

split_map() accepts common layer sources, including raster and vector files, with left_args and right_args for per-side rendering options.

m = leafmap.Map()
m.split_map(
    left_layer=swissimage_path,
    right_layer=hag_path,
    left_args={"indexes": [1, 2, 3]},
    right_args={"vmin": 0, "vmax": 10, "cmap": "plasma"},
    left_label="SWISSIMAGE (true color)",
    right_label="Height Above Ground",
)
m

Dragging the slider left and right reveals each layer. Areas with tall structures in the imagery should line up with high values in the height raster; if they consistently do not, that is a sign the two datasets are misaligned.

C. Split comparison for quality control

The same technique works for comparing vector annotations against their source imagery, which is one of the most useful checks you can run before trusting a set of labels.

m2 = leafmap.Map()
m2.split_map(
    left_layer=buildings_path,
    right_layer=swissimage_path,
    left_args={"style": {"color": "red", "fillOpacity": 0.2}},
)
m2

Key takeaways