Detecting Swimming Pools using Satellite Imagery and Deep Learning¶
- 🔬 Data Science
- 🥠 Deep Learning and Object Detection
Prerequisites¶
- 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¶
import arcgis
import sys
from arcgis import GIS, learn
from arcgis.raster import analytics
from arcgis.raster.functions import extract_band, apply, clip
from arcgis.raster.analytics 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
gis = GIS(url='https://pythonapi.playground.esri.com/portal', username="arcgis_python", password="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.
pool_bb = gis.content.search("SwimmingPoolLabels", item_type='Feature Layer Collection')[0]
pool_bb
pool_bb_layer = pool_bb.layers[0]
pool_bb_layer.url
m = gis.map("Prospect Park, Redlands, CA")
m
m.basemap = 'gray'
Now let's retrieve the NAIP image layer.
naip_item = gis.content.search("naip_ml", item_type="Imagery Layer", outside_org=True)[0]
naip_item
naiplayer = naip_item.layers[0]
naiplayer