Unsupervised Classification and Polygonization With QGis
Contents
- 1 Video Walkthrough
- 2 Introduction
- 3 Programs and Plugins Required
- 4 Acquiring Data
- 5 Unzipping Data
- 6 Importing and Displaying Data
- 7 Trim to Mask Area
- 8 Unsupervised Classification and Filtering
- 9 Polygonization (Raster to Vector Conversion)
- 10 Field Calculator
- 11 Editing and Merging
- 12 Map Production
- 13 Resources
Video Walkthrough
If you would like a video walkthrough please follow this link to youtube!
Introduction
There are lots of reasons for wanting to make a land cover classification. Whether that is to make beautiful maps, a temporal study of change or a more complicated statistical analysis. The goal of this tutorial is to be a jumping off point so to speak into the profound and complicated world of classifications.
In this tutorial we will be looking at how to perform an unsupervised classification; that is, a classification where the computer program chooses the classes without a training data set
Programs and Plugins Required
Qgis (3.22 was used in this tutorial) https://qgis.org/en/site/forusers/download.html
7Zip https://www.7-zip.org/
SCP Plugin (download through QGis)
Acquiring Data
For this tutorial pretty much any remote sensing data can be used. Depending on what data it it it may require pre-processing in order to produce a usable product, and that is outside the scope of this tutorial.
A good resource for free remote sensing data us the USGS Earth explorer. It involves making an account but it is such a good resource for remote sensing data that it is completely worth the extra step.
Sign up here https://ers.cr.usgs.gov/login
Now that you have made an account or signed into your existing account it is time to find the data to use.
You can use pretty much whatever data you see fit but Landsat8 is a very common choice and so that is what's being used in this tutorial. That being said the first step is to select which data set you want to use. To get to Landsat 8 image used in this tutorial select Landsat ->Landsat Collection 2 Level-1 ->Landsat 8 OLI/TIRS C2 L1
The next step is to pick the additional criteria. In this tutorial the image used was LC08_L1TP_046007_20200722_20200911_02_T1 this code can be copy and pasted into the "Landsat Product Identifier L1" text box.
Next step is to click results.
The results should bring up one image. Click on the footprint icon to show where it is on the world map (should be in northern Canada).
To download the image click on the download icon, the one with the little green arrow four icons left of the footprint.
Select the product options and right at the top click on the download button for the entire Landsat 8 Collection 2 Level-1 Product Bundle. It should be a big file (1.13 Gigabytes)
Unzipping Data
The data downloaded from USGS Earth Explorer is in .tar format and most windows machines are unable to extract that type of file without an additional program. You might have to download 7Zip (see Programs and Plugins Required)
To unzip the data simply right click on the file you wish to extract, select 7Zip and select extract here. This will not create a new folder it will simply extract the file into the folder that it is already in.
Once the extraction is done feel free to delete the .tar file as it is no longer needed.
Importing and Displaying Data
To import data, launch QGis and create a new project. once the project it loaded go to the rater tab at the top:
Raster-> miscellaneous -> Build Virtual Raster. This will open up the build virtual raster tool. Click the thee dots beside the input layers tab.
The input layers are going to be everything that was extracted from the .tar file. To do this use the:
Add Directory button
navigate to the folder where the .tar file was extracted and click:
Select Folder button
This will bring up everything from that file but not everything is needed. De-select every layer that doesn't end in B followed by a number.
The only layers that should be selected end with:
B1.TIF
B2.TIF
B3.TIF
B4.TIF
B5.TIF
B6.TIF
B7.TIF
B8.TIF
B9.TIF
B10.TIF
B11.TIF
Each file represents a different wavelength that the sensor collected. Landsat 8 uses a multispectral sensor so it collects the entire light spectrum across 11 wave lengths from blue to infrared. For instance B2 is blue, B3 is green, B4 is red NIR is B5 and thermal infrared is B11. Check out the USGS website for more information: