Springe direkt zu Inhalt

Creating Training Samples

Now that we have prepared our reference Imagery, we can set up our training data.
For the sake of this exercise, we will start with a very basic training data collection consisting only of point-features for the classes 'water', 'vegetation', 'urban', and 'bare soil', with each 20 features.
To create these features, we can simply use the Geometries-Tool at the upper left corner of the Map Panel to place point-geometries indicating a certain Land Cover Class at the cursor location. The Feature properties can be viewed and changed in the Map-Panels 'Import Geometries'-button.

For being able to properly use these Features for our classification, please make sure to assign an identical property-name for all classes and a unique value for all features within the same classes. For this example, we are going to choose the identical name 'landcover' for all classes, as we want to classify landcovers, and the ongoing numerical values 0, 1, 2, 3 for our individual classes.

Merging the Training Data

Now that we defined our desired classes, we will need to merge them into one featureCollection for being able to use them as training data.

var classMerge = water.merge(vegetation).merge(urban).merge(baresoil);
print(classMerge, 'Merged Classes');


// Now, we can finally start collecting training data based on our defined classes.
// To do so, we will use .sampleRegions. Please check the documentation to find out more about how this works!
// Also, keep in mind that .sampleRegions only works for Images, not for ImageCollections!

var training = s2a_median.sampleRegions({
  collection: classMerge,
  properties: ['landcover'],
  scale: 30
});
print(training, 'Training Data');