Showing results for 
Search instead for 
Do you mean 


Download Model and Data





This article is intended as a quick primer to get you started using some of the Machine Learning operators introduced with ERDAS IMAGINE 2018. 


There are two broad categories of Machine Learning classifiers introduced in ERDAS IMAGINE 2018. One deals with the broader category of Machine Learning which can be thought of as traditional classifiers (supervised or unsupervised) and includes Random Forest, Support Vector Machines (SVM), CART, etc. There's also a more modern, narrower sub-group referred to as Deep Learning.


This article will deal with the broader Machine Learning category by looking at the Random Forest algorithm. The same approach can be used for the other algorithm Operators which fall into this category (substitute Initialize SVM for Initialize Random Forest, for example).


The data we have to work with in our example is a 4-band CIR air photo (land_cover.img), a set of polygons derived from segmenting the image (unclassified_land_cover_segments.shp) and another set of polygons representing our training locations of known landcover classes (land_cover_training_data.shp), The screenshot below shows the training polygons overlaid on the image with the shapefile's attribute information displayed. The only attributes we start with are the landcover class names of the training polygons.


land_cover_training_data.shp overlaid on land_cover.img


What we are going to do in this scenario is use information derived from the airphoto at the locations of the training polygons to train the Random Forest algorithm. We are then going to use the trained Random Forest network (termed a Machine Intellect) to classify the segmentation polygons (i.e. to assign each polygon with the highest probability landcover type). We'll do the classification step using the same airphoto as an input, but the trained Machine Intellect could be used to classify other (similar) airphotos and polygons. It is important to note that we are not classifying the image. We aren't even classifying the geometries associated with the segmentation polygons. The Machine Learning algorithms are simply classifying the features - the rows of attribute numbers that are present in the database of information are what is important and used by Machine Learning. This is a critical point to understand: It is only by providing meaningful attribute information associated to each feature record that Machine Learning can learn (be trained) and then classify.


It is also a critical point to understand that for this broader category of Machine Learning algorithms, it is down to the user (designing the Spatial Model) to know and understand what types of information are appropriate to provide as attribute fields in order to classify the data into the desired landcover classes. This is in comparison to Deep Learning algorithms which tend to figure out for themselves what information needs to be derived from the training data provided.


For example, if trying to discriminate a Forest landcover class from a Grassland class, from a Water class, the designer of a Random Forest Spatial Model should understand that providing the NIR and Red color information will be important in differentiating vegetation from water, and texture is going to help discriminate between forest and grassland. And if we train a classifier based on these types of information input we will also have to provide the same type of information when it comes time to classify a different set of data. 


Training Model


With that in mind let's take a look at how the Training model has been constructed:




This simple example model has two inputs. The first is a Features Input which ingests the land_cover_training_data.shp shapefile and turns it into a Features steam. It's these Features that will form the primary set of information used by the Random Forest algorithm. But on input they are simply Features which only have two main attributes associated with them - the Geometry field and the Class known to exist at the location of the geometry. 


The second input is the Raster Input which ingests the land_cover.img airphoto. This raster stream will be used as the basis for extracting the attribute information we want to associate with the training Features.


So the two inputs feed into the next Operator which is a Raster Statistics per Feature operator. This has been set to extract the Mean DN  and Standard Deviation (SD) values per band within the spatial extent of the Geometry associated with each Features. In other words, each Feature record gains 8 new attribute fields, one for each band, containing the mean DN and SD value in that polygon. Other basic statistics could also be added, such as Mode, Median, etc. But for this simple example we just use Mean and SD.


The Features are then fed to the Kurtosis Texture per Feature Operator. Again this makes a measurement per geometry, but this time it is a measure of the texture of the imagery within the geometry extent. Again this information is added to the Features stream as new attribute fields and values, one per band. Note that the raster stream plays no further part in the Model beyond this point - it's the Features (and their attributes) that are used to train the classifier.


But we could have added far more sets of derived information to the Features if we were performing a true training and classification process. We might have derived information from band ratios, Tasseled Cap transformations, different texture measures, other raster or vector features sources (such as Slope and Aspect derived from a DEM), and so on. Just remember that what attributes you measure and use for Training also have to be provided when it comes to Classification. If you provided TC1 as an input when training, you'll need to be able to generate TC1 as an attribute field for the data to be classified. 


Next is the Select Attributes operator. The vector layer we fed into the model may have contained existing attribute fields that would play no (positive) part in constructing a Random Forest network. So it's important to identify exactly which attribute fields are going to be used in the Initialize Random Forest operator. One of the attribute fields must identify the "Classes" you are interested in (in this case, the Name field) as well as all the attribute fields you have identified as providing information that helps discriminate between those classes. So effectively you could perform Machine Learning using just Features (you don't even need Geometries), so long as you have all the attribute information you need associated with the Features. 


Then it's straight into the Initialize Random Forest operator. this "crunches the numbers" and constructs a random forest network which best describes the relationship between the Classes and the attribute information associated to each of those classes. Once constructed (trained) this network can be used to ingest other sets of attribute information and separate them into their most likely class matches. But we don't do that in this model - we just train and then feed the network to the Machine Intellect Output operator to create a file which encapsulates the trained Random Forest network.


By limiting the Training step to its own Model we can train once and then re-use the Machine Intellect file to classify multiple times in a separate Model (without needing to re-run the training step each time). This is the more common way of approaching Machine Learning. But if we just had one set of data to train and classify, you could combine the Training Model and the Classification Model (described below) into a single model and not output the Machine Intellect file.


Classification Model


Now let's take a look at how the Classification model has been constructed:




As mentioned above, when classifying you need to provide the same attribute fields that you used to train the Machine Intellect (the Random Forest network in this instance). So one of the biggest time-savers you can make for yourself when constructing your classification model is to copy / paste the majority of the "attribute generation" steps (including the Input operators) from the Training model to the Classification model as a starting point. This way you are more or less guaranteed to set the Classification model up correctly to supply all the necessary training attributes populated and named in the manner expected by the trained Machine Intellect. 


Really then all that's required is to add the Classify Using Machine Learning operator fed by a Machine Intellect Input operator and a Features Output to write out the features with the Class association made to each record. You can also add any clean-up operators you might want to use as well, such as a Merge Features to dissolve the boundaries between neighboring polygons with he same Class. But in this example we've left it simple. 


So in this Classification model we have three inputs:


  1. Features Input is the input vector layer that you wish to classify. In this case it's the segmentation polygons that we don't have an already known class for (unclassified_land_cover_segments.shp)
  2. Raster Input is the raster layer that is going to be used to populate attributes onto the Features stream. In this instance we're using the same raster layer again (land_cover.img), but more normally it would be a different image (covering the same extent as the features to be classified)
  3. Machine Intellect Input identifies the trained Random Forest network produced by running the Training model above. This network will then be used to classify the Features stream.

The model then measures all the attributes and associates them to the Features stream and feeds those, plus the Machine Intellect, to the Classify Using Machine Learning operator, which "crunches the numbers" and produces output Features that have a new attribute filed identifying the most probable Class for each feature. This particular model is set to also create and populate Probability fields for each class assignment. The screenshot below shows the classified features overlaid on the airphoto


Output features containing landcover classification attributes produced by the Random Forest classifier


There you have it - simple example models showing the theory behind training a Random Forest machine learning network and using that network to classify other data. In this instance we classified the Features. However it is certainly possible to apply the same techniques to directly classify a raster image (and produce a raster classification layer), but in that instance you would use point features to train the classifier. That process will be the focus of a further Spatial Recipe. Or, more likely, an eTraining video, as will the process for using Deep learning and also the Machine Learning Layout.

by Technical Evangelist
on ‎04-30-2018 11:34 AM

The first batch of eTraining videos for Machine Learning are now live. Check this link and over on the right-hand side you can click on the Machine Learning Label to filter for those courses.




on ‎08-18-2018 11:14 PM

decision tree output?

on ‎05-14-2019 02:51 AM

I can not run this models, I don´t have a professional license. Could you please edit the models so it is possible to run them outside the professional module?


Are there some licensing limitations on the category of operators that can be launched with IMAGINE Advantage?

For example, If I want to run a model with classification operators, can I launch it using Imagine Advantage?

on ‎10-10-2019 02:58 PM

Data doesn't contain the point file.

by Technical Evangelist
on ‎10-10-2019 03:10 PM

Hi Justin,


These models don't use point geometries. They use two sets of polygons (derived from image segmentation) - one is the set used to train and the other is the set which gets classified.


You can use point geometries, but this example does not.


Hope that helps.