Difference between revisions of "Unsupervised Classification and Polygonization With QGis"

From CUOSGwiki
Jump to navigationJump to search
Line 55: Line 55:
 
B10.TIF<br>
 
B10.TIF<br>
 
B11.TIF<br>
 
B11.TIF<br>
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:
+
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:https://www.usgs.gov/faqs/what-are-band-designations-landsat-satellites?qt-news_science_products=0#qt-news_science_products<br>
  +
With all the correct bands selected hit the ok button.<br>
  +
Change the resolution to highest<br>
  +
Check the box for place each band in separate band file.<br>
  +
Click run<br>
  +
The image should be displayed in the QGis project. The colouring might look weird and that is because it is currently a false colour composite. To change it to a natural colour composite<br>
  +
Right click on the Virtual layer-> select properties-> select symbology<br>
  +
Select Band 04 for red<br>
  +
Select Band 03 for green<br>
  +
Select band 02 for blue<br>
  +
Click apply and then ok to close the window.<br>
  +
Now it c=should be a natural colour composite.
   
 
== Trim to Mask Area ==
 
== Trim to Mask Area ==

Revision as of 12:51, 23 December 2021

Video Walkthrough

If you would like a video walkthrough please follow this link to youtube!

https://youtu.be/H06wWFFNtgU

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:https://www.usgs.gov/faqs/what-are-band-designations-landsat-satellites?qt-news_science_products=0#qt-news_science_products
With all the correct bands selected hit the ok button.
Change the resolution to highest
Check the box for place each band in separate band file.
Click run
The image should be displayed in the QGis project. The colouring might look weird and that is because it is currently a false colour composite. To change it to a natural colour composite
Right click on the Virtual layer-> select properties-> select symbology
Select Band 04 for red
Select Band 03 for green
Select band 02 for blue
Click apply and then ok to close the window.
Now it c=should be a natural colour composite.

Trim to Mask Area

Unsupervised Classification and Filtering

Polygonization (Raster to Vector Conversion)

Field Calculator

Editing and Merging

Map Production

Resources

Unsupervised Classification using SCP: https://fromgistors.blogspot.com/2021/01/unsupervised-classification-using-scp7.html
USGS Earth Explorer: https://earthexplorer.usgs.gov/
Loading Landsat 8 into Qgis: https://www.youtube.com/watch?v=mBk2VIMawRE
Raster Conversion: https://docs.qgis.org/3.22/en/docs/user_manual/processing_algs/gdal/rasterconversion.html?highlight=raster%20vector
USGS band designations: https://www.usgs.gov/faqs/what-are-band-designations-landsat-satellites?qt-news_science_products=0#qt-news_science_products