This case is about building classification based on binary classification, which uses the machine learning function to automatically extract building vector polygons from image data in a certain area. The application example mainly introduces how to perform data preparation and model training after configuring the relevant Python environment when no model is available, and then perform binary classification on the imagery according to the model.
1. Prepare Sample Data
Draw labels on partial zonal data within the source image data to be classified via binary classification, and use them as sample data to generate training data. The main operation steps and parameter description are as follows:
- Open the video file: Open the image.tif data in resources_ml\example_data\training\binary_cls_train_data\raw as a file database, and open this image data in the map.
- Prepare sample image data: Create a new file datasource: Sample.udbx, clip two images with rich building colors, save them in the Label datasource, name the result data as Sampleimage_1 and SampleImage_2. After clipping; export the two image data as TIFF data; and drag SampleImage_1.tiff and SampleImage_2.tiff to the current workspace to open as a file database, and add them to the map window respectively.
- Prepare sample tag data: Create new region datasets SampleLabel_1 and SampleLabel_2, and add them to the SampleImage_1 and SampleImage_2 image data maps respectively; set the SampleLabel_1 and SampleImage_2 layers to editable state, and vectorize the buildings in the image data via Features -> objects -> Polygon -> Polygon. The vectorization result is as shown below:

2. Generate Training Data
Based on the label data and image data from the first step, generate training data for the two datasets separately and store them in the same path. The main steps and parameters are as follows:
First Set of Training Data
- Function Entry: Toolbox -> machine learning -> imagery analysis -> training data generation.
- Source Data: Set the image data as SampleImage_1, and the label data as SampleLabe_l.
- Image Size: Set both the number of rows and columns to 512;
- Training Data Purpose: Select Binary Classification;
-
Output Path: Set the model's export directory to E:\AI\Data\TrainingData;
- Data Name: Set to: building_training_data.
- After successful execution, you will obtain images divided by the specified size from the image data and label data, as well as the data's configuration file building_training_data.sda, as shown below:
Second Set of Training Data
- Open the Training Data Generation tool in the toolbox again.
- Source Data: Set the image data as SampleImage_2, and the label data as SampleLabe_2.
- Image Size: Set both the number of rows and columns to 512, same as the first set of training data;
- Training Data Purpose: Select Binary Classification;
- Output Path: Set the model export directory to be the same as the first set of training data: "E:\AI\Data\TrainingData";
- Data Name: Same as the first set of training data, set to: building_training_data.
- After successful execution, the second set of training data will be appended and saved to the same path, with the result as shown below:

3. Model Training
Use the training data generated in the second step for model training. The main steps and parameter description are as follows:
- Training Data Path: Select the save path of the training data result generated in the previous step: E:\AI\Data\Training\building_training_data;
- Training Config File: Select the config file from the training data result: resources_ml\trainer_config\binary_cls_train_config.sdt;
- Training Model Purpose: Binary classification;
- Training Times: 10;
- Training Log Path: E:\AI\Data\TrainingModel\log;
- Model Storage Path: E:\AI\Data\TrainingModel\Model;
- Model Name: building_model.
- Use default parameters for other parameters. The execution time is about 10-70 minutes (GPU execution time). After successful execution, the building_model model file is obtained.
4. Model Application: Extract Buildings from Imagery
Use the model obtained from model training and the binary classification tool to perform large-scale building polygon extraction on the source image data, automatically extracting building information from the imagery. The main steps and parameter description are as follows:

- Source Data: Set the source data to image.
- Model File: Select the result model generated by model training, i.e., the "E:\AI\Data\TrainingModel\Model\Building_model\Building_model.sdm" file.
- Slice Overlap Value: Set to 60.
- Use default parameters for other parameters. Click execute to perform binary classification on the imagery and extract building information, obtaining the raster data as shown in the figure (right) below. (GPU time is about 15 minutes)
Related Content
Machine Learning Environment Configuration
Classification of Ground Objects