This post is a tutorial for the collection of ROIs (Regions of Interest) using the Semi-Automatic Classification Plugin v.1.5 for QGIS. For information about how to install and configure the plugin see here.
A ROI is a portion of the image (a sample of pixels), which is used as input for the land cover classification. In particular, each ROI identifies a particular land cover class; consequently, the classification algorithm will classify the entire image, according to the given ROIs.
The Semi-Automatic Classification Plugin collects ROIs as polygons in a shapefile.
For more information about GIS and remote sensing definitions see my previous post here.
- First, download the sample dataset from here, and extract the file (if required, download the open source extraction software from http://www.7-zip.org/).It is a subset of a Landsat 8 image (data available from the U.S. Geological Survey), acquired in the South of Rome, Italy.The following bands (16 bit) are included in the file: 2 (blue), 3 (green), 4 (red), 5 (Near-Infrared), 6 (Short Wavelength Infrared 1), 7 (Short Wavelength Infrared 2). Therefore, the first band in the image file corresponds to the blue (2), the second band corresponds to the green (3), and so on.
- Start QGIS and load the multispectral image. You can simply drag and drop the file sample_landsat.tif inside the QGIS interface.
- Now we are going to create a colour composite "R G B = 4 3 2" (it corresponds to "R G B = 5 4 3" for Landsat 8), which will be useful for the ROI class identification (especially for vegetated areas that appear red).
- Right click on sample_landsat layer (in the "Layers" panel) and click on "Properties";
- In the "Style" tab of the "Properties" window, select band 4 as Red band, band 3 as Green band and band 2 as Blue band;
- Under "Load min/max values from band" select "Estimate" and click the "Load" button;
- Under "Contrast enhancement" select "Stretch to MinMax";
- Click "OK" to apply the settings.
- We are going to create a shapefile that will store the created ROIs. The Semi-Automatic Classification Plugin needs a shapefile with specific fields for the ROI creation.
- Therefore, the most convenient way to create this shapefile is to click on the "Create new shapefile" button;
- A new window will ask you the new shapefile name (for instance "ROI") and where to save it (we can choose the same folder of the Landsat sample);
- Once created the new shapefile, the name thereof should appear in the "Layers" panel and under the "Select a shapefile" combo box (in case the name is not displayed you can click on the "Refresh list" button).
- Now we are going to create the first ROI. ROIs must be representative of a land cover class. This plugin allows you to create ROIs using a region growing process (i.e a segmentation of the image, grouping similar pixels).
- Click on the "+" button near "Create a ROI" (this is required for the pointer activation);
- ROIs are created by clicking on any pixel of the image; click on the dark area in the South, which is the Lake Albano (use the scroll in order to zoom in);
- After a few seconds the ROI polygon* should appear over the image (a semitransparent orange polygon).
*Attention! This is a temporary polygon, which is inside the group "Class_temp_group" in the "Layers" panel. It is convenient to order this group as the last item in the "Layers" panel, for the purpose of showing the last created ROI only (the previous ROIs will be hidden). Simply drag the group name downward.
- We need to save the ROI to the shapefile.
- Under "ROI definition" type a brief description of the ROI in the field "Information" (for instance "water"); this description is not used in the classification process, but it is useful in order to distinguish the created ROIs;
- Leave unchanged the 1 in the field "ID", since it is our first ROI; the ID (i.e. identifier) will be used as reference for the land cover classification, therefore it is important that each category has a unique ID (that is ROIs of the same class can have the same ID);
- Click the button "Save ROI to shapefile" and the ROI will be saved as a polygon in the shapefile.
- Now we are going to create the second ROI.
- Click the "+" button near "Create a ROI";
- We create the second ROI of built-up land cover (with this colour composite, built-up areas appear grey/light blue); click on a pixel of the grey area near the lake;
- Wait a few seconds, and the ROI polygon should appear.
- We can change the ROI settings, in order to create a better polygon that include the whole area we want.
- Under "ROI settings", change the "Minimum ROI size" value, which is the minimum area (in number of pixels) of the ROI (for instance 110);
- Under "ROI settings", change the "Maximum ROI width" value, which is the maximum side (in number of pixels) of a square that can inscribe the ROI (for instance 150);
- Click the "Redo" button**; this button creates a new ROI exactly at the same point of the image you have clicked before;
- As usual, after a few seconds the ROI polygon should appear; as you can see the ROI is larger than the previous one, and it includes more built-up pixels.
**You can also change other ROI properties, such as: the "Spat. Radius", which is the spatial radius that defines the neighborhood where similar pixels are grouped; the "Range radius", which defines the spectral interval where pixels are considered similar (the interval in the multispectral space, in radiometry unit). In most cases, it is sufficient to change "Minimum ROI size" and "Maximum ROI width" values.
- Save the second ROI to the shapefile.
- Under "ROI definition", type "built-up" in the field "Information";
- Change the field "ID" to 2 (you can click on the up arrow, in order to increase the value by one); we set a new ID, because this ROI is a new category;
- Click the button "Save ROI to shapefile".
- Now we are going to create a third ROI.
- As usual, click the "+" button near "Create a ROI";
- We are going to create a ROI of vegetation; click a point in the image that is very red (for instance in the left part of the image);
- After a few seconds, the new ROI should appear.
- The new ROI is created, but it is quite difficult to discern the boundaries thereof, because of the image colours. You can change ROI colours and transparency.
- Select the "Settings" tab; move the transparency bar (for instance to 35%), and click "Change colour" button (for instance, select yellow and click "OK");
- Now select the "ROI tool" tab and click the "Redo" button; the ROI is more visible in the image.
- Save the third ROI to the shapefile.
- Under "ROI definition", type "vegetation" in the "Information" field;
- Change the "ID" field to 3;
- Click the button "Save ROI to shapefile".
- If you realize that you have saved a wrong ROI (for instance because the ROI area is too small, or the ID is wrong), you can undo the last saved ROI.
- Under "ROI definition", click "Undo save ROI";
- A prompt will ask you if you really want to delete the last saved ROI. If you click "Yes", then the last ROI is deleted from the shapefile. Now click "No", because we want to keep the ROI.
- It is possible to create a ROI by drawing a polygon, for example because you want a very large ROI area.
- Select the "ROI" layer in the "Layers" panel and click the "Toggle Editing" button (the pencil icon);
- Draw a polygon by clicking on the image (for instance, in the dark vegetated area near the lake), and left click to close the polygon;
- A prompt window will open; type "4" in the field "ID_class", and "vegetation 2" in the field "ROI_info"***;
- Click the "Toggle Editing" button again and click "Save" in the prompt window to save the ROI.
*** Maybe you are wondering why we have created another vegetation ROI. That is because the spectral signature of this vegetated area is very different from the previous ROI (you can see it is darker). In order to produce a good land cover classification we need to create a new ROI for this area too.
In the end, we have created a training shapefile, which will be used in the next tutorial (here) for the land cover classification of this image. If you want, you can download this shapefile from here.
|ROIs created using the Semi-Automatic Classification Plugin for QGIS, for a Landsat 8 image|