Supervised Image Classification with QGIS

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right guys let's walk through how we can perform supervised image classification with qgis now if you don't know what supervised image classification is that's okay by the end of this video you're going to know exactly what it is I'm not going to give you a definition here because I think it's more valuable to get into it and to learn it as we go the first thing we need to do with qgis make sure you have it open like I do here and then we need to install a plug-in that will help us out a whole lot with this image classification so go to plugins manage and install plugins go to all plugins here and we're going to search for the semi-automatic classification plugin which you see here so go ahead uh and install that plugin let's take just a minute to install here it should be pretty quick and there we have it I'm going to close my plugins page here my plugins window and you can see it's added a few things you'll notice here we have this SCP dock and up here we have a couple of toolbars I'm going to take the stock and I'm going to drop it on like this uh and then drag it over like this so they have it takes about a whole side panel there if you don't see this the way you can get it is you can go to view you can go to panels and down here it's cut off the screen but SCP dock is down there um the same thing if you don't have those toolbars go to toolbars and the SCP coolers are cut off down at the bottom but they're they're down there just make sure the check mark is turned on for those and you will have them now the next thing we need to do is add some data if you don't have data I have videos and blog tutorials on how you can get satellite data for free those are linked to from the article that has directions for this which is linked in the description I'm not going to go over it I'm just going to add in some data that I have and those data are going to be in the data for my full remote sensing with qgis course which you can access in the description below so I'll go to data to my courses um remote sensing data and we're going to work with some landsat 9 analysis ready data and here you can see I have data for these seven landsat bands I'm going to select all seven of those and I'm going to drag them in here all right so now I have these bands I'm just going to minimize their symbology so we can see all of them a little more easily now that I have my data in here I can create a band set for the semi-automatic classification Plugin or we'll call it SCP for short so I go up here on the top to SCP I can go to band set and you can see here my single band list doesn't have anything in it if I can click this refresh button and that adds in all seven of those bands I can select all of those bands with this button here or I can go in and select them individually by using the control or the shift button and once I have them selected I can click add and that adds them to band set number one okay so this band set is now created now what we need to do is we need to Define some Legions of interest that will help the algorithm determine how to classify land cover this is where the supervised aspect of supervised classification comes in we call it supervised classification because we are giving labels to the computer to determine what land cloud or classifications to make the computer trains a model based on our supervised class inputs before we can do that we're going to want to get a color image up here that's really easy to do with SCP I'm going to give it the band combination 4-3-2 which is red green blue for landsat and if I hit enter there this is going to generate this virtual band set down here now when I drag this up to the top you will see that I now have a color image that I can look at just like this now I can make this um false color infrared which I believe would be five four three and if we hit enter you can see now that virtual band set has turned into this color infrared let's go back to 432 and now we have this color image so now the thing we need to do is we need to make some regions of Interest these are our training labels that we'll use to train an algorithm to do this open up the SCP doc click on the training input tab here and we need to create a training input file I'm just going to put this in my downloads and I'm going to call this youtube.scp which will automatically be added onto the end and we will click save here to start that file now this file is going to contain all the information about the spectral signature of the regions of interest that we create and once we have this file created we can start adding regions of Interest which is very simple to do I'm going to come up on the toolbar and I'm going to click this button here which will help me create a region of Interest so click on this button now you can see I have crosshairs here so let's say that I want to create a region of interest for water which is represented by this Lake I'm going to come down here I'm just going to start left clicking to place vertices on a polygon and I can create a region of Interest here and when I'm done I right click and it completes that polygon now once that polygon is complete I want to come over here to the bottom left hand corner of my SCP dock you can see I have a macro class ID mcid and the class ID my macro class I'm going to name water I'll leave the id id is one my class ID I leave is one and I will name this flake and once I've done this I'm going to come to this button down here that says save temporary Roi to training input and this will save it to that input file and put a record in this list so let's go ahead and click that you can see that it's working on calculating the signature and saving I'm just going to pause the video while this finishes it might take just a minute okay so you can see that my region of Interest over here or my sorry my class my macro class of water has been added with the class of lake that has been added down here and now if I go back over to my layers you'll see I have this YouTube layer that's been added that contains my rois if I drag that to the top you can see this region of Interest displayed here okay let's go do some more regions of Interest go back to my doc I'm going to do some more water while I have it pulled up here I am going to come over to this location here where there's maybe an algal bloom and I'm going to make a region of interest for water over here and right click and region of Interest we got that our macro class ID is one I'm going to keep this class one I'm going to keep a lake and I'm going to save that once again I'll pause while this finishes okay oh and look you can see that I made a mistake and I uh made that three instead of one that's okay we'll do another link once again so I can show you the right way to do it um I'll just make one more polygon over here on this Lake right click change this to one like water and we will save it okay so you can see the record was added and it has macro class and class ID of one we're going to classify based on macro class ID so I make mistakes on class ID it's not a big deal all right uh now let's just come up here and let's get just some water class on this River so I'm going to make a region of interest for this River here and I'm going to make this class id2 call it River still macro class id1 and let's save that all right now let's go look for some other macro classes we can identify here we could do some for agriculture we could do some for kind of uh bare Earth if we look at some more of our image over here you can see that we have some snow and we have some Forest areas we have some more bare Earth areas so let's start and do some more like bare earth type of thing so this looks kind of like a some kind of I don't know Landslide or glacial outwash or something we'll call this spare earth looks Rocky I could be wrong it's not that important for this tutorial so we're going to change this macro class to two and we'll change this to four and so this will be we'll just call we'll call it we'll call it bare Earth and it looks like it's locks and we'll save that signature all right let's go uh find another location to work on let's come down here um we have some varying Hues of land cover here let's kind of outline this brown one it looks like it's probably soil and it's spare Earth it's we'll put it in class five and we'll call it soil and let's save that while we're in this area let's make another Roi and we'll just assume that all this is soil even though it could be shrub land we don't have the data to really inform us and so we'll just do our best uh in a real situation you would probably want to have some well you for sure would want to have some on the ground data to ensure that the classes you're making here line up with what's really being seen on the Earth's surface we'll save that one also with soil and this tutorial is really designed to give you an idea of how to do this as far as the technical side of it there's also kind of the scientific method side of it which would require you to um have uh logical justifications in place for the data you're collecting now let's do one more bare Earth and we'll assume that this over here is rock also which was class four and let's go ahead and save that okay now let's go and uh get some agriculture here so we'll start a new macro class for agriculture or maybe we'll just call it vegetated actually to simplify our classes so we have some vegetation here and we'll call this three vegetated and we'll call this agriculture and class six three vegetated agriculture so those things look like we have those set up correctly and we will save this okay and uh let's find some vegetation that's maybe slightly different than that let's come up to this here and we'll create another region of Interest and it will also be class six three vegetated and we'll save that and uh while this is saving I'll just let you know that if you are interested uh in a more in-depth tutorials on a remote access to with qgis I have a full course on this with over four hours of video instruction uh it goes to downloading your own satellite data into accuracy analysis um and you can get that at the link in the website or a link in the description okay uh now let's go find some Forest that's also vegetated but might have a slightly different signature and so we'll go over here to this more mountainous region um and we have some maybe more shrubby vegetation in this area so let's go ahead and create an Roi for this and um we'll give this macro class seven and we'll call this middle just call this natural it doesn't matter a lot because we'll we'll classify based on macro class ID but we'll just kind of keep this somewhat accurate here and uh we'll get this saving and let's just get one more class of forest here kind of maybe this dark shadowy forest and so we'll come in and select this area here and we'll also name this class seven open I need to right click to close that and then we'll save this signature now one thing to know is I'm just going to do these three classes when you're doing this for a real application you'll want to have classes that represent the different nuances in lancover because everything is going to be assigned to one of these classes and if you noticed in this image we have some snow and if I only use three classes it's not going to classify the snow accurately by any means because I haven't accounted for that with my class structure so you want to make sure that when you're doing this in a real application setting that you account for all those classes so that everything fits nicely into something and this is for my printer how lovely um like I said this is an example to show you how to do the technical side of this there's also kind of this logical scientific process side that takes a lot more background knowledge especially of the area that you're working in okay but we have all these Roi set up we've saved the signatures have been saved to our data file and now we can go in and actually train a model uh that's going to work on this for us so the first thing we can do is we can go into SCP band processing and classification and here we can set change some settings so you'll notice here that um we have our input band set which we have band set one since we want I can use mcid which is what I want to do you can also use class ID if you would like and we have an algorithm which is minimum distance Max likelihood or spectral angle mapping you can play around with these I'm just going to show minimum distance for this example um I'm going to leave this unchecked for the land cover signature classification we're okay here and the classification output we can load a style in here or apply a mask we're just going to do this basic and I'm not going to click run because I want to show you something that we can do to test our classification before we actually run it and the way we can do that is by using this classification preview now what I want to do is most of my rois are over on this side of the image I'm going to come over to this other side of the image to see how well it classifies in an area that I haven't trained on as much so I'm going to click this preview button here if I click on that and I can come over here when I click on an area it's going to generate a preview for me and this will take just a minute for this preview to generate once it does you can see here that it has been degenerated and it's really hard to see what is going on uh largely because my colors over here have not been set well so I can change these Colors by double clicking on it and I'll just change these macro class IDs so water I will change that to blue and then better Earth can stay the same and vegetated actually can also stay the same so I can click this button now to refresh my preview and this will take just a second to load up and there we go you can see that I have that water vegetation and better Earth classified if I go to my layers panel you can see that I have this temporary layer here that gives me those classifications and their colors and I can turn this on and off to kind of verify how well my classification is doing you can see that it's picking up water pretty well but it's also picking up Shadow as water in some places here and the vegetation is turning out pretty well now I can go over and I can click this add button to try my classification in a new location so if I want to click over here I can Center it on this uh urbanized area or slightly urbanized area and generate a new preview in that location and we can see what that looks like you can see that it picks up that River and if we look at this urban area you can see that it's a mix of vegetated and better Earth which makes sense and then you can see that it's picking up the the vegetation and the soils relatively well in these other areas and finally once I feel good about my classification preview if you test this preview in some places and don't like it you can go in um over here and add more classes add more rois for each class whatever you think you need to do to improve that classification and once you have it ready you can come in here to SCP you can come into band processing classification and you can click run over here and now when you click run it's going to give you um the uh you need to set a file name so I'll call this my YouTube classification and I will save it and this will take just a minute to run and to complete that classification when it's done it's going to come out and add that layer into qgis and it's going to be classified in the same manner as you set your colors for your classes in the SCP doc and so remember if you're interested in more about this there are two Avenues to learn that there's the free Avenue which includes um YouTube videos and post on the blog many of those are linked uh in the article on my website which is linked in the description and there's also the remote sensing for qgis course which has a more tutorial guided option there you can see here that this classification is about 50 done we're still working on it and it'll get done here in just a minute okay so my classification has been added I can close this window out and go go with my layers I can remove this temporary layer now and you can see that I have those three classes predicted over the entirety of my satellite image and that is how you can perform it on supervised classification with qgis if you're interested in other classification techniques you can check out my videos on unscrew my video on unsupervised classification as well hope you enjoyed this hope this helped you expand your knowledge of pgis if you have questions you can always ask in the comments and to learn more check out the resources Linked In the description thank you for watching
Info
Channel: Open Source Options
Views: 6,563
Rating: undefined out of 5
Keywords: open source, open source options
Id: QP_0_1tWw0o
Channel Id: undefined
Length: 21min 13sec (1273 seconds)
Published: Tue Jan 17 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.