Supervised Classification for Land Cover Mapping with Landsat 8 in Google Earth Engine

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone uh welcome to this lecture on this lecture um i'll teach you how you can apply a machine learning uh classification algorithm uh which is a supervised classification uh using the urge engine cloud competing and will be by the end of this tutorial you'll be able to convert a satellite image here into a land cover classification map you know the good thing about this is you can change the steady area to you know a choice of your study region or your country and apply this code and derive a language land cover map by the end of this tutorial um so um before we get started um if you are new to earth's engine uh if you're if you're aware of forza engine or if you're currently using garza engine disregard this this part but if you're new to earth engine uh i'll just like to give you a brief demo about what erz engine is before we get started to the machine learning you know the details uh of this this presentation um so uh if you're new to arts engine type in google earth's engine and so google earth engine is a cloud cloud computing platform provided by google and this platform has been um on um um so this platform has been uh for several several years now uh google is providing this for um non-commercial uh use for academics and research purposes and and currently they have launched another commercial version for for a commercial uh purpose but for this video we'll be using a non-commercial version for educational or research um uh use and if you are new to earth engine you'll go ahead and click this sign up button and in the sign up button you'll um fill in a a pretty short form and your information and also um the reason why you um are applying for the errors in account mostly for a you know training um a purpose or um you know research uh reason and um and um mostly they'll provide access in the next 24 to 48 hours so and then you need to have a gmail account um i think for for this um uh to to work and once you have a nurse engine account then we can get started and apply this machine learning uh application using big rs observation data uh we'll be using a satellite data landsat satellite but before that let me give you a brief overview for the engine and if you click here on ours engine you have a few options the first main one is the code editor so the code editor is where you know the main code api playground where we'll be using um in this presentation uh so we'll be writing our quote uh here and um writing our mission learning classification so let's write our first uh code here print um you know hello world um [Music] if you are new to this uh will just help us get started world and if i print this uh this is just uh any uh you know code editor playground if you click run here you execute your hello world so so this is a you know a playground for javascript javascript version um so ours engine has a few options one of it is a python api and the other one is a javascript so i'll be using the javascript uh version which is um really a robust um you know api was many visualization and and whatnot compared to the python you know the python api as as well has some um you know advantage in some situations um you know for example you can use uh you know use it in a collab or jupiter notebook and then you'll be able to pull in some of the the cool you know data science uh libraries and and and and whatnot so these are some of the uh you know various uh apis so let's get back to um the urs engine platform just to give you a background if you're new to earth engine again so you have data sets here if you click to data sets you have you know library of data sets about five petabytes of datasets currently on the earth's engine api so you have you know data from satellite uh to climate data satellite data you know weather and atmospheric data you can see here satellite data we'll be using um this landsat satellite in our tutorial here today uh and you have you know landsat you know collection um landsat has different uh you know instruments the landsat 9 landsat 8 and landsat 7 and some of the legacy landsats here and then you have a library of datasets it's it's you know modis uh high resolution data and then some land cover data this is one of the recent recently launched dynamic or land use land cover data and some nighttime light and you know cropland there is a whole lot of you know data sets on the urgent you can also click some of this um you know tabs here and you can choose um you know whatever data you're requesting you can type it and just search it from the library so um i think this is good for your introduction if you're new to earth engine let's go back to our edit code editor let's just uh clear um this um you know pages here uh so before we get started to the the machine learning classification i just would like to give you a brief intro about you know the uh you know supervised classification on the earth engine api um so in this tutorial as i mentioned we'll be converting you know bigger's data uh you know landsat data as you can see here uh for steady region into a land cover map uh as you can see it on the right and we'll be using you know supervised classification algorithm currently a cart uh so a cart is a classification and regression three model on the urs engine api so in the earth's engine api we have so when you run a classification the earth engine will give you the classification output in three different types so the first one is a classification um you know input out output class and a more like a binary class or a discrete class in in in this case we'll be using this in our example we'll provide we'll be providing um you know an integer values for the different language land cover classes and then our model output could also be a discrete value or an integer for example for water body it's zero for urban it's one so this is more like a discrete classification output the other option is if you're using a classification regression for example your output will be a continuous value um you know when you say a continuous it would be for example um you know 0.4 or 5.3 or something like that it's not like an integer a discrete integer value it's a continuous data value right and the last one is a probability class for example you can also output um for example if you're classifying your a water map for example a water and not water body all right a water in non-water class so you can also output um the uh probability of that class the probability of that class to be a water for example 80 probability for that class to be water so you can also output that probability values as an output of that classification and the other thing is that you know these are not all supported in all classifications so so for example the first uh you know the regression uh output approach is supported by svm support vector machine and cart classification and regression trade and the other probability uh you know uh outputs are supported by cart name base uh and svm and so when you know when you run a classification you need to do a you know a few things right so the first one is you need to prepare your image data if it's a landsat or a sentinel or amoris you need to import or prepare your data your input data that goes to the classification right and the second thing is you need to prepare a label land cover data for training you have to either generate a training data or you have to um um you know imports and already existing training data so that's the second thing you need to have when you run a supervised classification because your model needs some sort of training data a training label for each of the land cover classes that you're generating okay because it's a supervised you have to supervise you know the model it's if you were running unsupervised classification you don't need a training data but in this case you need a prior knowledge or training data for the model and um you know spectral signature for the land cover types this is for just your own you know visualization to look at the different spectral signature for each land cover class uh it doesn't necessarily go to the model but it's just for exploratory analysis um and then once you have your training data you need to train a classifier okay so you need to provide us that input training data and extract the the uh the spectral signature from the landsat or or the sentinel whatever you know satellite data you're using you need to extract and then train a classifier and then next thing is you need to apply that that that classifier and generate um an image a final output image which is technically a land use land cover classification map all right and the last thing in a supervised classification actually is you know to ask us whether your classification or your land cover map is good or bad and how accurate is it so that's called accuracy assessment after classification so you need to do all of these things and then um we'll be doing all of these things some in our in our coding um in the next um session okay and now let's uh you know get to let's get to coding okay all right so let's get started so the first thing is to um you know import you know a land cover um sorry a study area uh you know we want to focus our study er because we're using landsat data right so we need to um we need to um have you know established we need to have already established a steady region so let's let's get um that done out of the way so the first thing is i'll just um you know maybe write a title here uh countries so for countries i'll import uh i'll just declare variable called countries here and i'll be a poll importing a feature collection so i'll write feature here and the name of that um actually i can import that um you know file from uh from ours engine already and this is the lsib 27 that's uh um and i can copy it or just you know import it however it's easy for you i can copy it here and then close this and then i can paste it here so instead of this easy and i need only one a bracket okay you need to close that and it's uh a semicolon and next one is uh this is so this is a word countries database right so i need to um choose one country in this case i'll be using ethiopia so that's my roi region of interest and then i'll um call countries this one or just copy paste that okay and then i need to filter a specific country so using this data i need to if you if you want for example if if for example if your country is different from this um hopefully it is and just choose your own country and apply this this approach if you're in india or usa or germany or brazil um it really doesn't matter so this model can apply to any country so just simply change the country in your case and that way you can generate a you know you can follow along and generate a language land cover map based on this tutorial okay so i'll filter ee filter and equal and then so the country's name is stored in a parameter called country name so provide that so that means which country do i need in in my example it's ethiopia but you can change it in your case if you want to run this model for a different country okay so now let's just uh visualize this you know to make sure that we have already uh you know imported this appropriately okay so i'll call map add layer [Music] and i'll call my roi here and um i don't need to just provide any coloring or anything just you know give it a name ethiopia it's just a boundary right and i'll call it false um the reason is that i don't want to show up i don't want this map to show to show up here once i execute that i want it here but i don't want it to show up on the map so that it's turn it off that's what this false uh declaration is in it because i want to adjust the map the zoom level i'll create a map center object okay and then roi all right so let's just execute this what it does is it will just change it to um my study area but let me just change the zoom level probably about eight so now i think let's just do it six a little bit okay this is good so it's zooming to a steady region that i i need to select for this analysis now i imported my you know roi my steady region for this analysis and the next step is actually to import the landsat image okay and um so let's get started and import the landsat image um so what i'll be using in this in this um example tutorial is um using the simple composite landsat algorithm which can remove cloud contamination and whatnot so we'll have a clear mosaic cloud free image for our analysis in this case okay so let's just drag this a little bit down and let's scare it up um and then just let's create a title make um a cloud free a cloud-free composite okay in this case landsat 8 okay all right so let's create a variable called um image so our landsat will be image so i'll call the earth engine algorithm algorithm algorithm its algorithms right and then landsat simple composite simple composite okay so by pulling this this is an already existing erzingen algorithm uh which does um remove cloud contamination from your landsat image which is a simple um you know algorithm um so we'll apply that and it does have so you need to provide the image collection for this one so it does need a collection [Music] and so all right landsat 8th row we'll be importing this data after we finish this function okay and then filter date so this is a long time serious data for example onsite 8 you know starts from 2013 so that's um you know many years now right so you need to uh specifically filter for you know a certain year in our case it will be 2020 okay so filter date is um used to filter the landsat uh image collection um for a specific time period okay and i'll provide my start time and in time in this case all right 2020 there are one there one january um first of 2020 and the last day would be december 12 december 31st rather 2020 okay and the next one is to actually um you know define whether you want to keep it as flawed you want to keep it as flawed right um we define that true that way we'll just keep the data as flawed okay so this is our function you will import the landsat image and apply um a cloud removal algorithm which is the erzhengen built-in algorithm okay and filter it by date and that's it so but we don't have this image collection already imported so we'll go ahead and import it from earth engine so landsat one side eight so a landsat eight i'll just choose you know the raw scene right and then i'll import it here and name it just like this one l8 wrong here so when i name it here it will import it and then i can call it here so it this name has to be exactly the same as the so that's why i renamed it here so i i renamed it here so this image instead of writing all the i mean so the other way is to copy paste this you know image collection and just you know write it here but instead of that import it and just rename the image collection and copy that and paste it here we have already done that but just you know for you to understand why do we do that why why we do that so instead of you know writing you know the image memorizing the image collection we import it here by just typing searching it here and then um replace it here in the function okay so what this does is it will import the landsat image collection and remove clouds using the simple composite errors engine cloud removal algorithm let's just you know plot the landsat data right so we have imported it let's um you know make sure that um it's good for our classification so let's uh first create a visualization parameter var is true color i'm doing a true color comp a true color visualization parameter here okay and then i'll provide some um you know parameters here okay so let's uh input that's those parameters uh the minimum value here is zero and the maximum value is 0.3 that's the uh the landsat band values okay and then i'll need to define the bands for this visualization in this case um band 4 bands 3 and band 2 of the landsat 8 so b4 is band the red band and the green band is b3 and the blue band is b2 for the landsat 8 now this will uh you know create uh our visualization for for you know displaying the map the landsat data that we have processed and imported over here okay and just in a quick second here and so finally let's just add our landsat data over here add layer and then here i'll import the landsat the cloud freelancer data i'll copy and paste it here paste it here and uh i'll just clip this because it's um it's a large uh area so i'll just clip it by my region of interest over here roi right i'll copy that and then paste it here and um after that i need to provide the visualization parameter i have already created i'll copy that as well here so that when it when i visualize you'll just have that visualization parameter and finally i'll just create simple composite name this is just you know the name um you can change this if you want to it doesn't matter this is just when i execute this code it will show up here as a layer okay so you can see here this has already been executed so this is the boundary for our study region it's showing up so once we execute the other one the landsat also shows here okay let's just uh execute that code and now we'll be able to see our landsat image a cloud-free landsat image for our steady region fantastic so this is a pretty clean you know cloud free image for the year 2020 and we can use this to generate a long distance cover uh classification um you know using a supervised classification in this case cart and i think this looks good so let's just uh you know go ahead and you know what the next step now is we have imported our lan side image which we'll be using um for the uh you know classification or machine learning classification now the next step is actually to you know generate the training data right so let's just um you know generate a training data um so before that let's just create something like here create training data so for any classification for any supervised classification you need training data the training data is an already known data points like sample data points for known land cover classes and then you input that or you feed that to the model and the model will will train the the landsat image based on those known sample data points and then finally we'll output a large land cover map for any place in the study area or for the entire study area got it so so you know when you have a supervised classification as i mentioned earlier there are two ways that you can feed the model training data one is you generate a new training data yourself which we'll be doing here i'll show you in a bit and the other one is import and already existing training data so let's just create a training data ourselves but before that um let's just um you know write the class the label class that we need to uh you know we need to use in the classification in the in the in the cart classification so uh i'll create a variable called label so this is the um the [Music] the um the response uh variable that we'll be using okay so i'll just call it class okay so that will be used in our model and the other one is what bands do i do i use i have landsat landsat 8 you know bands which brands am i using so i have to provide that here and it will select based on this you'll select the landsat uh you know eight bands and then we'll apply them to the classification so i'll be using landsat band one band two and i'll be using bands three this is in the supervised classification and the next one is band four bond five and band seven you can you can choose different band combination for for your case but this is just uh for this demonstration um you know choosing uh this bands you know in your case for example you might even add the thermal bands right so but in this case i'll just um be using only these bands and the other one is just let me close this in a semicolon all right okay next up is um let's write once we created uh training um you know data once we created a training data you know we will need to merge it so let's let's write that function and then once we create a training data it will automatically merge and create uh another variables for us and so just so that you understand let's write for example here in this case um you know provide water class here in this case i'll provide water class as one and urban two we'll need this when we create the the training data that's why i'm writing it here so that we don't have to memorize that sorry this is one and the other class is you know forest or crop and the next one is forest and last one is barren right okay so we'll be using uh all of this when we create uh the um you know the classification so this will be uh we'll be generating um um you know water urban you know crop forest and barn so about five um you know different land cover classes in your research if you're interested you can expand the land cover classes but for this demonstration this is you know suffice okay so so let's create a function that will merge all of the different um training variables so i'll call them training so this training will have our brand class so i'll merge so it has urban and then merge it also has forest class actually crop and it also has merge of we have urban crop and water and merch and we have um forest the last one is we have barn okay i'll close that so you have urban crop water forest and barn okay now the fun part is to create actually the you know classification the training the training data okay so what we'll do is we'll just digitize all of these classes uh manually uh based on our knowledge of the area and based on high resolution imagery all right so this is our study area okay and we can choose any um any data point within this study area okay so i'll actually choose the background and add the satellite the landsat satellite data and sometimes i can also use the google on you know the google map uh the google satellite data rather so the first class is um so if you want to create a training uh label in this case you'll click this this is a urgent geometry features um that help you create some feature class or vector data point or a polygon a line or a box so in our case we'll choose this um add marker and then when you click that it will automatically generate a data point here but we need to modify that i'll first call it um water and i'll change it from geometry so geometry is uh it doesn't have attribute it's just a coordinate information but in our case we need attributes so that's why we're changing it to a feature collection here and i'll change the color to blue and then property that's where you add the value remember the class um so put it zero so you remember the class i created here um so the label this is exactly what what it is okay so my my um you know model um model parameter will be class so i'll be uh inputting all of this training values as class that's why i'm just if you change this one you it has too much um it has too much um this this one here class so if i change for example to something else then i'll have to come and then change the training parameter or property into exactly my matching what what that change is all right so for example if it's you know a type or something then you have to also go and change this as type so the main thing is this really doesn't matter you can change it to anything but these two the attribute value and the training data as well as your label here in the model has to match that's the main thing okay so now we have created our um our water class and if you click it it will just turn into it has to be bold to start digitizing now it's bold anything i digitize will be stored as water so let me start from uh you know this area so this is like tana the um the um source of the the blue nile and then you know in northern ethiopia so just go ahead and digitize you know create every time you click you'll automatically generate a data point if you like if you go here so every time you create you know data points you can see here it's just changing so it's storing it automatically it is importing it as a feature table here it's naming it water here and it's matching exactly that so it's it's pulling it in the code editor so this number change every time i create a new point this will change you can you can observe that 9 10 so i can go um and generate another let me just change this into pan to zoom around to other places where maybe we will have water uh or just you can change it to satellites or this are some areas with uh water body or likes and then i can go ahead and highlight the water and then click so now i'm uh generating or creating my training data for the classification and in this case a water class and you can change it to a satellite view so this is the water area so we have to make sure that we're just clicking everything within the water water area and there are also some other leg types i think the terribility in these two different lakes are different so that's why there are different colors anyway so here okay i think that should be fine we have enough you know water class and the next the next one is so the next one is to actually um create an urban class uh i think i'll just use the uh the google maps and this is adisaba area so i'll zoom in since we are doing an urban um you know an urban class i'll just go ahead and then create a new one the next one is an urban class i'll create a new one so i'll call it urban and change it to a feature collection and i'll call you one and probably a red class here yes okay let's just create that cool and it's highlighted then i can start digitizing so these are like buildings right you can zoom in okay so these are buildings so i can just go ahead and create training uh sample over you know the building areas and some on a highway yeah this is a highway and and then some in the buildings i think these are big buildings here okay and maybe this areas some storage or some industries on here all right i think this is good uh let's just go ahead and create the next class which is forest uh cropland sorry all right so let's create another one and let's just create another one here i'll create another one here a new layer and it's highlighted so let's just create crop oops crop and feature collection here and i'll do class and um i'll do two and some yellow color here all right so let's just find some you know agriculturalists just use the pan zoom area here so [Music] probably outside the city area right some of this area should be a cropland areas so it has uh you can see the pattern for the crop field here so i'll go ahead and digitize those let me just highlight that okay and will automatically cr generate that crop uh feature class here training there's only two data points here so i'll go ahead and digitize oops it's changing from time zoom to let's just highlight again then we can start digitizing let's just go to another place over here so these are all crop areas okay another crop area here these are all crop areas okay um let's just go to another place okay these are all agricultural areas all right this should be fine and next one is let's create our [Music] let's create our forest glass all right so first class here i'll choose class and three and then i'll just touch some green color all right forest class it's highlighted here let's find something from the [Music] satellite data but also oh there's a a nice uh force cover here uh we can go ahead and create that let's make sure that's like highlighted okay zoom in a little bit okay so we can go ahead and do our first class so it's automatically creating the training site here the training data here on the code uh editor let's just um change the area a little bit so this is forest cover pretty dense forest cover here all right a little more okay i think this should be fine and the last class is actually a bar in class so i'll go ahead and create new layer which is byron okay so for boring class i'll create a property class is here and i'll give it class 4. all right so bar and area let me just use the pan to go to san barn area in the study region as you can see okay where's my map here's my steady region i don't want to go outside my steady area so i have you know collected fairly dispersed throughout the study region i think this area let's just change it to a satellite image so this looks like mostly burns so let's go ahead and highlight the barn area okay and over here as well okay and okay i think we have enough data for this one so now we have uh completed our um training you know capturing our training data all of the training classes are here uh we have a water class urban crop forest and barn so these are you know separate uh tables or features so let's merge them all of them together so that we have one single training table okay so this is what we are doing by by this is how we are doing it by merging all of this here so we have training here so i'll call the urban class here and next i'll call the crop here and then the water here and the forest here and lastly the urban so this function will merge all of this into a single table okay so let's just go ahead and execute that um okay what is going on here so the urban is oh there's a typo here yeah that's why all right let's say execute that um that's because of the typo really there's another typo okay we don't have here this type well here's all right should be perfect all right so we have now our training data we imported the landsat image and then we have generated uh training data and then merged that into a single table so now we'll be using this training table into our classification okay okay so now we have created our training data now the next step is to overlay this create training data over the satellite image right so let's do that so the first thing we need to do um to overlay the image uh these these points or over the satellite image is let's just um create a title on the landsat image right so let's overlay these points uh let's create a variable so we have now you know a training point here and a lot of satellite data right we need to overlay them so that we'll be able to run them in the in the classification model so i'll create a variable train image okay and then input so one thing we need to do is we need to create an input for the model right so the input is just the satellite image but with this bands right if you simply use the image you'll use all the landsat buns but if you use the only if you if you use only the selected buttons here then what you need to do is just import this image okay and then you need to select um the the bands right so select instead of everything i'll just copy that and then bans right so what this does is when we're in the model we'll be using only these this bands this uh you know this bands bond one two three four five and seven of landsat 8. so in our model we'll be using this image instead of using the image we'll be using this input which has some selected uh landsat 8 bars okay so i'll be calling this input here so for the image i'll be using this and then for the training i'll call the training so and i'll be using sample regions or the engine built-in function sample regions what this does is it will extract the landsat bonds for all of these bands um using the points that we have generated or the trainings that we have generated earlier so that's what it's doing and let's create a curly bracket here and in our curly bracket it so this function the sample region function it requires two things the first thing is um a training label a training data and also the label you see the label is a class that's what we have created when we do the training so it needs a table in this case this is our training table and also what uh what parameter or what attribute am i using to do the classification so we're telling it okay use class here we declared it as a variable label so we need to call that here so the first one is the collection so the collection is what training data am i using okay so we need to provide that training data here so i'll copy this training data here so i've already used the landsat image here as input with the selected ones and the next one is to input the training data which is here and then within this training data which parameter or which field am i using so i'm telling it use properties class or label in this case so properties is so label label is this one right so i'll just be telling the the the sample region parameter to use that that parameter which i needed for the for our model classification so now what we have done here is so instead of let's call this function so what this function does is it will merge the satellite data and the training data together okay so we have our image and input here based on this the band selection and we have our training data here this sample region function will actually overlay the satellite data with the training points that way this trend image has is ready to run the classification so we have everything we have the different bands so this data this table has all the bond value the landsat 8 band value and also the training class level the land cover class level which is water crop plant you know forest and whatnot okay so this is you know we're almost close to run our classification now and the next thing we can do is this is a table we can just test run you know write print and then test run you know if it makes sense do we have all the landsat 8 in advance and we have also the land cover training datasets let's just print and see what we have trained image we're printing this overlaid dataset here i'll just copy paste instead and close it let's let's execute that code to print that training data and just look at uh you know it's it's running so let's just wait a little bit and okay so we have about 225 training points so in this case it's not only the land cover classes but also because of this overlaying of the landsat image it's also extracting the landsat bands all right so now this is our final training data with all of the landsat bonds you see the bond one one two one three band four band five and seven so these are the landsat uh reflectance values we'll be using in our model and also the training class for example one is urban zero is water right you remember when we do the classification the training i'm capturing the training data here so that's what it is here so this is almost ready to go to the uh model classification okay so we are almost done preparing our training um data for the final modeling all right all right next is uh let's um you know let's um you know um generate the data because for any classification right for any land cover mapping you need to do accuracy assessment so for the accuracy assessment you know let's divide this data into two so we'll be using eighty percent of the data for moral training and twenty percent of the data for model validation or you know accuracy assessment so let's do that here so what we'll do here is um we'll create a random you know column all right so let's just create a random column which is let's create this variable training data okay let's import this um this training data here and then um random column this function will create a random column with numbers right and so this random column i'll split the first one as training data okay so the first one is train set so my train set is a training data and using this random column i'll split it 80 percent of the data to a training and what i'll be doing is filter here ee filter okay less less than um i'll call the random the random field here i created here which is created here right so using that random field anything less than 0.8 or 80 percent will be classified will be categorized as my training data okay and the other one let's just create the evaluation data test sets so my test set will be for evaluation all right i'll just call the same training data here training data here and instead here instead of less than all these creators all right uh greater than equals greater than or equals okay and then i'll call that random field the call the single quotation has to be inside and they're 0.8 so anything uh leads down there 0.8 will be um um sorry greater than will be um or 80 will be stored as a test variable so what this is is that 20 of the data is split for evaluation or validation and eighty percent of the data is will be used as uh a model training okay so now next step is we'll be using this in our model classification the first one the training data all right so the fun part is finally let's do our model classification so we'll be using the earth's engine built-in machine learning classification here so let's write a topic here classification uh classification model in this case it's a cart so regression tree a cart and regression tree uh classification and regression three here and so let's create a variable called classifier so we'll be applying this training data into the cart model okay that's what we're doing here and so we'll be using the earth engine built-in classifier smile cart is the urzingen built-in model okay i think there's some typo here that's why we have okay so every time you use an urzingen built-in model you will change the color here okay so if it doesn't change there's something was the um with the with your um okay so if it doesn't change color there's some type or something like that so make sure that if it's uh you know a nurse engine built-in function it will show something like this purple color okay and so what i'm doing here is uh urgent classifier smile card train so i'm training the the model the machine learning classification model using my training data and later i'll apply the classification the first thing is so which data am i using the 80 percent of the data which is train set right so i'll be using the train set here and also i'll be using so from this data which um which label which attribute am i using the label right this label here the class okay so that i need to provide that and the last thing is which landsat bands am i using to apply the classification so this spans so i need to provide the bands and that's it so we're now what we're doing is we are providing the we're training the model the cart model by providing our training data train set here and a label what level are we using in the classification so we're using the cla the language land cover classes stored in the class label so we need to use that and lastly for the landsat image um which bands are we using in the model we have already selected that here so we're just providing that so this will train our cart machine learning model okay and so once we execute this we execute that now the model is built something is going on here so [Music] there is some typo here we have to fix okay ee filter to do okay filter e filter greater than or equals okay so all equals there you go this has to be capital that's why all right we don't see any hopefully any error message here perfect cool all right so we have now built our model so now the model is already trained the cart classification supervised classification model is already trained so the model knows what water body is what crop plant is what urban area is so we have literally trained the model okay so we have trained the model that in all of these areas okay you know for landsat band band 7 this is you know what a water body classic nature looks like this is what an urban you know class signature looks like within the spectral uh you know the spectral uh band so next time if i wanna you know ask you to tell me what within my study area what this land surface is then the model will tell you that's what what we're doing here so technically once we apply the classification or once we apply the model to a landsat image it will convert the image into a land use land cover map that's the next step what we are doing is apply this model to our landsat image this image okay instead of this image because this image has all the thermal and um you know the thermal bands as well as the the um the visible bands and whatnot so we only need the you know this this band's selected so we we we provided the input so let's do the the fun part now let's apply this image to um you know to our landsat landsat satellite image so classify the image to the landsat image right so let's classify the landsat image based on our model so this is our classifier this is a model so let's just uh apply this model to our image so let me create a variable called classified alright so this classified will store the final classified image okay and then i need to provide the lan side image where is my lan side image my lan site image is input because this one selects all of the spans that i need in the classification so i'll copy that okay and then where's my model here's my model the classifier i'll copy that and i'll say classify so this is an earth engine built-in model to apply classification to a satellite image and then so i have my landsat image and i need to provide the model where's my model here's the model the classifier the car classifier and if i execute that i'll have a landing land cover classification okay so what i'm doing now is um when i execute this let's go ahead and execute that fantastic so what we'll have here is um a land cover classification map okay and that classification map is already available now once we execute that i mean we can definitely visualize that and you know so we can visualize that and if we need to and export it and whatnot so let's just um take a closer look at on on that all right so um here what we are doing here is um let's just export like let's visualize the the map right let's visualize the map okay so before we do that we need to create some visualization all right uh let's just create a visualization okay or just define visualization all right so we're doing uh we're defining a visualization here so it's already the land cover map is already created but let's just create a visualization parameter like coloring and things like that for the land cover okay and then we'll visualize it so i'll create a land cover palette right okay so my land cover palette stores some colors so i'll just um you know you can you can pick this from color blue or you know other color um you know application uh but just i already know this story about these things um you know you know the other option is just to provide some simply you know blue right and for water class and maybe for urban rate okay and then for a forest green maybe hopefully this works and for crop yellow maybe all right and then for um barn just gray right [Music] here um and that's it we need a one comma and close our square bracket and then just the final part is map outlay all right okay and then our final language land cover classification using a supervised um algorithm and then i'll call that in the map layer it's listen since it's big you know just clip it using my uh region of interest i have a region of interest here so i'll be using my roi to clip that data i'll just use clip function okay and then i'll add a palette right i've already clicked created a color palette let's just create a curly bracket and then um create a pallet okay and then import that land cover pallets i think this is okay copy that okay and then let's just define a minimum and maximum actually for this visualization so mind you the minimum is a water class 0 and the maximum is 4 which is a barring class right so i think this is ready to go and we can just we can you know write some title here you can you can do a land cover or anything just maybe i'll do classification okay classification map or land cover class what not all right so this is our final map let's just go ahead and execute that so when you execute that this landsat image will be converted using our supervised classification into a land cover map let's see execute that might take a little second since this is running on google's uh you know uh computers uh super computers um on the cloud so it's just taking a little while yeah let's see so now let's just uh uncheck this so that we can visualize this so this is our land use land cover map classification um you know as you can see here we have imported this landsat 8 image and we have converted that into a landisland cover classification i mean this is not perfect this is just by any means not perfect um you know but this is just a simple example that you know to demonstrate that um you can um you know run a machine learning um you know algorithm on the cloud using big data this is this is large data i mean you know a 30 meters pressure resolution for for you know a large country like this and running it in a few minutes it's it's unprecedented this is great um so you know this is just for a demo purpose it's not a perfect classification you know as you as you can see all of the data points that we have captured are like about 50 or 40 so it's not it's not um you know um it's not recommended for research but if you are really doing a public publishing a publish of research you need to provide a really careful uh carefully created training samples um and if you do that like for example for each of the class if you have you know in hundreds or about like a thousand data points for steady region your classification would be really really good um and so uh you know that's um you know how you uh generate a land use land cover map using a supervised classification in this case cart classification regression tree and you'll be using that and capturing a training data you'll be able to convert a landsat satellite image into a classification all right thank you
Info
Channel: Spatial eLearning
Views: 19,891
Rating: undefined out of 5
Keywords: google garth engine, earth engine, google earth engine python api, earth engine javascript, earth engine python, google earth engine tutorial, google earth engine download, python qgis, remote sensing, landsat, sentinel 2, supervised, supervised classification of landsat, supervised class, supervised classification of sentinel-2 images, supervised classification of landsat 8, machine lea, machine learning, deep learn, data science, data science full course
Id: kNkARZWEDjw
Channel Id: undefined
Length: 72min 20sec (4340 seconds)
Published: Mon Aug 22 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.