Pixel-based Classification Workflow with arcgis.learn
¶
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¶
As an example, we use land cover classification to demonstrate of workflow of pixel-based image classification using arcgis.learn
. To begin with, we need input imagery as well as labels for each pixel. With the ArcGIS platform, these datasets are represented as layers, and are available in our GIS. This guide notebook showcases an end-to-end to land cover classification workflow using ArcGIS API for Python. The workflow consists of three major steps: (1) extract training data, (2) train a deep learning image segmentation model, (3) deploy the model for inference and create maps. To better illustrate this process, we will use World Imagery and high-resolution labeled data provided by the Chesapeake Conservancy land cover project.
Export training data for deep learning¶
Import ArcGIS API for Python and get connected to your GIS¶
from arcgis import GIS
gis = GIS("home")
Preprocess Training data¶
To export training data, we need a labeled imagery layer that contains the class label for each location, and a raster input that contains all the original pixels and band information. In this land cover classification case, we will be using a subset of the one-meter resolution Kent county, Delaware, dataset as the labeled imagery layer and World Imagery: Color Infrared as the raster input.
Notes:
- The raster and labeled imagery layer both are required to be '8 bit Unsigned' when the raster is a RGB layer such as world imagery.
- The Labeled imagery layer should be a thematic raster with pixel values corresponding to the label class value.
- The pixel values should range from 1 to n, where n is the total number of classes.
- Any NoData value should be mapped to 0, as portions of image with nodata values would be ignored in while exporting training data.
label_layer = gis.content.search("Kent_county_full_label_land_cover")[0] # the index might change
label_layer
m = gis.map("Kent county, Delaware")
m