- 🔬 Data Science
- 🥠 Deep Learning and Instance Segmentation
Building footprints are often used for base map preparation, humanitarian aid, disaster management, and transportation planning
There are several ways of generating building footprints. These include manual digitization by using tools to draw outline of each building. However, it is a labor intensive and time consuming process.
This sample shows how ArcGIS API for Python can be used to train a deep learning model to extract building footprints using satellite images. The trained model can be deployed on ArcGIS Pro or ArcGIS Enterprise to extract building footprints.
In this workflow, we will basically have three steps.
- Export Training Data
- Train a Model
- Deploy Model and Extract Footprints
Training data can be exported using the 'Export Training Data For Deep Learning' tool available in ArcGIS Pro as well as ArcGIS Enterprise. For this example we prepared training data in 'RCNN Masks' format using a 'chip_size' of 400px and 'cell_size' of 30cm in ArcGIS Pro.
from arcgis.gis import GIS gis = GIS('home')
The item below is a feature layer of building footprints for Berlin.
rcnn_labelled_data = gis.content.search('MaskRCNN_training_data_Berlin', 'feature layer') rcnn_labelled_data
You can use the 'Export Training Data' for Deep Learning tool to export training samples for training the model. For this sample, choose RCNN Masks as the export format.
arcpy.ia.ExportTrainingDataForDeepLearning("World_Imagery", r"D:\data\maskrcnn_training_data_maskrcnn_400px_30cm", "berlin_building_footprints", "TIFF", 400, 400, 0, 0, "ONLY_TILES_WITH_FEATURES", "RCNN_Masks", 0, "classvalue", 0, None, 0, "MAP_SPACE", "PROCESS_AS_MOSAICKED_IMAGE", "NO_BLACKEN", "FIXED_SIZE")
This will create all the necessary files needed for the next step in the specified 'Output Folder'. These files serve as our training data.
This step would be done using jupyter notebook and documentation is available here to install and setup environment.
from arcgis.learn import MaskRCNN, prepare_data
prepare_data function takes path to training data and creates a fastai databunch with specified transformation, batch size, split percentage, etc.
data = prepare_data(r'\data\maskrcnn_data\buildings\', batch_size=4, chip_size=400)
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.