ArcGIS Developers

ArcGIS API for Python

Download the samples Try it live

Change Detection of Buildings from Satellite Imagery


The World is changing every day and monitoring that change on ground can be a tedious and labor intensive task. so, is there a way to automate it?

This notebook will walk you through how deep learning can be used to perform change detection using satellite images.

One of the popular models available in the arcgis.learn module of ArcGIS API for Python, ChangeDetector is used to identify areas of persistent change between two different time periods using remotely sensed images. It can help you identify where new buildings have come up for instance. This model is based upon the latest research in deep learning and works well with objects of various sizes. The ChangeDetector model workflow consists of three parts:

  • Preparing the training data,
  • training a model
  • using the trained model for inferencing.

Let’s first prepare the training data.

Export training data for deep learning

In the cells below, we have provided the input rasters and input mask polygons needed to export training data.

In [1]:
from arcgis.gis import GIS
gis = GIS('home')
In [2]:
input_data = gis.content.get('3ebf8ca5f6c245d69e2e0f4358986ed3')
Image Collection by api_data_owner
Last Modified: December 10, 2020
0 comments, 85 views
In [3]:
mask_polygons = gis.content.get('6ee0b48611c44b31b499f6cbe202686f')
Feature Layer Collection by api_data_owner
Last Modified: December 10, 2020
0 comments, 153 views

ChangeDetector model requires data in this folder format : images_after, images_before and labels folder. The label indicates where there are changes in the before and after images. These images are too large to process in the GPU memory for training the model, so we need to create small image chips or tiles. Training data can be exported by using the Export Training Data For Deep Learning tool available in ArcGIS Pro as well as ArcGIS Image Server.

  • Input Raster: 2014rasters
  • Tile Size X & Tile Size Y: 256
  • Stride X & Stride Y: 64
  • Meta Data Format: 'Export Tiles'
  • Environments: 0.3

As shown below, the above tool needs to be run thrice each for image before, image after and the change labels in order to create training data.

Model training

This step would be done using jupyter notebook and documentation is available here to install and setup environment.

Necessary imports

In [3]:
import os
from pathlib import Path
from arcgis.learn import prepare_data, ChangeDetector

Get training data

We have already exported the data which can be directly downloaded using the steps below:

In [4]:
training_data = gis.content.get('d284e2083b254f6b8508f9cf41f53713')
Image Collection by api_data_owner
Last Modified: December 10, 2020
0 comments, 4 views
In [5]:
filepath =
In [6]:
import zipfile
with zipfile.ZipFile(filepath, 'r') as zip_ref:
In [7]:
data_path = Path(os.path.join(os.path.splitext(filepath)[0]))

prepare_data function takes path to training data and creates a databunch with specified transformation, batch size, split percentage, etc.

In [8]:
data = prepare_data(data_path,

Visualize training data

To get a sense of what the training data looks like, use the show_batch() method to randomly pick a few training chips and visualize them. The chips are overlaid with masks representing the building footprints in each image chip.

In [9]: