Random Forest (ViGrA) Classification in SAGA

From CUOSGwiki
Jump to navigationJump to search

Tutorial on preforming Random Forest Classification using R

Purpose

This tutorial will demonstrate how to perform a Random Forest classification in SAGA using the ViGrA tool. Random Forest(RF) is esemble of decision trees, that can be used to perform a classification. This tutorial is done in the SAGA software, using the Random forest classification (ViGrA) tool. The method, data, tool, and validation will be explained in detailed.

Introduction

Random Forest is an ensemble of decision trees...Further explanation. Website It is used in many applications such as regression, calculations, classification etc... website for. Why its awesome. website Additional information can be found on random forest at Wikipedia link here -->>> RF

What is RF classification RF, Types of scripts RF

Software

The software used is SAGA 2.1.8 the older version 2.0.8 does not contain the Random Forest Classification (ViGrA) tool. This tool comes from the producers of (VigrA) VigrA. SAGA new version can be found at RF

Data

The data that is needed to perform a supervised random forest classification is variables which are dependent on the users data. a classification can be done on a simple 4 band image and can iculded to many variables. Also there is a need for training data, where 70% - 75% of the training data should be used as classification and the other 30% - 25% should be used as validation data. The tools operation is done with the use of polygons, therefore if you have a training data set that is in a point file it needs to be converted into polygon, I recommended buffering your point file, to create a polygon) explained in tutorial how to perform this.


TUTORIAL for Classification

Uploading information into SAGA

To upload files into SAGA, use your mouse and go to File->Open, from here a load screen will appear, click on the bottom right corner of the screen and select the all files tab, select your files and click open

Openfiles.png

To visualize your data, select the data you would like to display and click on Add to Map

Creating Training Data(Points) for each class

To create training data, the over all data set has to contain a minimum of random 100 points. We will create 3 classes of point files for the classification(water, forest, and urban), the water class will be demonstrated below. (note that forest and urban classes are created in the same fashion).

to create a point file, we start by creating a new layer file. Select geoprocessing->shapes->add new shape file

CreateshapeSAGA.png

Name your class for points, and make sure the shape type is selected to be points

SettingsforpointsSAGA.png

Now a point shape file has been created, however we must add the individual points still, to add a point right click on the created layer and add to map to ensure that the layer has been activated.

AddpointtomapSAGA.png

You will see a small screen, asking which map to upload the shape file to, as I will be creating a class for water I will select the image band that best represent this class, in my case NIR band.

MaptoloadtoSAGA.png

Too add a point, activate the add shape feature that is in the Edit-->Add Shape

AddshapeSAGA.png

Now that the shape file add has been activated, we can create a point file by selecting the action tool in the bar

SelecttheactionSAGA.png

Then select the area in which you wish to create the point and click, a small square with a circle inside will form, that represents the location that you chose, to finalize the creation either press enter or double left click on the mouse and click on the only option to edit selected shapes.

CreatepointSAGA.png

Repeat the add shape process for the water layer file to keep adding points to the layer. Add enough points that will allow you to properly sample the area. I would recommend a minimum of 30 points per class.

You should have a training data set now of points that resembles the following image.

ThreeclassesSAGA.png

Buffering and Merging layers

The points need to be converted into polygons which is achieved by buffering the points. Points have to be individually buffered before they are merged. To buffer a point file select shapes->tasks->Shapes buffer

BufferlocationSAGA.png

In the menu that pops up, select the buffer distance to not set and then select a appropriate buffer size, I chose 10 for my classification, the higher detailed that your training data is in you can select a smaller size, or if the features are very similar you can choose a larger buffer size.

BuffersettingsSAGA.png

Once you have created the three buffer files, you can merge these polygons together to create a single data set of polygons for your classification training data. To merge layers select the Shapes->Construction->Merge Layers

MerginglayersSAGA.png

Then you have to select the layers you wish to merge(making sure they are the buffer layers).

MergingsettingsSAGA.png

You will have your overall polygon training data set to be used in your classification. NOTE you should have a smaller cross validation data set created as well following the same steps however only using 25-30% of your total points.

Running the classification

Open the imagery->Classification->Random Forest(ViGrA)

RFtoolSAGA.png

Then upload all the image bands you wish to load by selecting the Gridsystem you wish to use, and then the Features you wish to upload.

Featuresset.png

Select the number of trees you wish to create and other settings. (note that it took approximately 3 mins to run on a intel i7-4790K 4.00 quad core processor) Refrain from running larger trees then this unless you are allowing it to run overnight.

ALLRFsettings.png

This is what the final image will look like

RFclassification1SAGA.png

Tutorial for editing map collours

How to change the colours in a map for better visual representation.

Now that you have successfully performed a Random forest classification, the output map is colour displeasing.

To change the properties of a map we must ensure that the properties tab is activated. to activate the properties tab click on the window tab and select the show properties

File:ObjectproperitesSAGA.png

Then choose the lookup table options

File:ColourproperitesSAGA.png

From here change the colours into your desired format

File:Colourproperites2SAGA.png

Then you will have your final product

FINALPRODUCTRFSAGA2.png

Conclusion

What it produces and the limitations

References