ArcGIS Developers

ArcGIS API for Python

Detecting Swimming Pools using Satellite Imagery and Deep Learning

  • 🔬 Data Science
  • 🥠 Deep Learning and Object Detection


  • Please refer to the prerequisites section in our guide for more information. This sample demonstrates how to do export training data and model inference using ArcGIS Image Server. Alternatively, they can be done using ArcGIS Pro as well.
  • If you have already exported training samples using ArcGIS Pro, you can jump straight to the training section. The saved model can also be imported into ArcGIS Pro directly.

Introduction and objective

Deep Learning has achieved great success with state of the art results, but taking it to the field and solving real-world problems is still a challenge. Integration of the latest research in AI with ArcGIS opens up a world of opportunities. This notebook demonstrates an end-to-end deep learning workflow in using ArcGIS API for Python. The workflow consists of three major steps: (1) extracting training data, (2) train a deep learning object detection model, (3) deploy the model for inference and create maps. To better illustrate this process, we choose detecting swmming pools in Redlands, CA using remote sensing imagery.

Part 1 - export training data for deep learning

Import ArcGIS API for Python and get connected to your GIS

In [1]:
import arcgis
import sys
from arcgis import GIS, learn
from arcgis.raster import analytics
from arcgis.raster.functions import extract_band, apply, clip
from import list_datastore_content
from arcgis.learn import SingleShotDetector, prepare_data, Model, list_models, detect_objects 
arcgis.env.verbose = True
from arcgis.geocoding import geocode
In [2]:
gis = GIS('', 'arcgis_python', 'amazing_arcgis_123')

Prepare data that will be used for training data export

To export training data, we need a labeled feature class that contains the bounding box for each object, and a raster layer that contains all the pixels and band information. In this swimming pool detection case, we have created feature class by hand labelling the bounding box of each swimming pool in Redlands using ArcGIS Pro and USA NAIP Imagery: Color Infrared as raster data.

In [3]:
pool_bb = gis.content.get('3443553a9e8443eeb570ef1b973e44a8')
SwimmingPoolLabelsFeature Layer Collection by api_data_owner
Last Modified: July 07, 2020
0 comments, 251 views
In [4]:
pool_bb_layer = pool_bb.layers[0]
In [5]:
m ="Prospect Park, Redlands, CA")

In [6]:
m.basemap = 'gray'

Now let's retrieve the NAIP image layer.

In [7]:
naip_item = gis.content.get('2f8f066d526e48afa9a942c675926785')
naip_mlImagery Layer by arcgis_python
Last Modified: April 14, 2020
0 comments, 0 views
In [8]:
naiplayer = naip_item.layers[0]