Calculate percentage of land use per subcatchment in QGIS 3

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi I'm Hans from the cross lecturer at ihe Delft Institute for water education in this video I'm going to show you how to derive the percentage of land use land cover in different sub catchments for this purpose I will use a polygon shapefile of catchments these are sub catchments in the Ruhr in Germany and we will use the land use from the Korean land cover data from the European Commission but you can download easily from the internet from the compare nika's website you see the warning that it's not yet validated data from 2018 but I will still use it for the demonstration of course you need an account to download it and then you have a choice of different file formats and we'll use here this Q Lite database because that's easy one to use with QGIS and this one is a raster format and just ESRI you database it's big so I already downloaded it so here you see the database and there's the polygons with the land use land cover data in it I'll drag it here here you see all the polygons let's first style and when you download it it comes with a style file and you can choose the file from the legend folder that comes with the data and if you choose the qml that's already the QGIS styling file and we do load style and there you see all the classes make sure that you choose the right column which in this case is code 18 and these are the land use codes and that's then the name of the land use land cover class as you see there are three digits and there are the different levels as part of this demonstration I'm also going to show you how to aggregate this to the main land use land cover categories such as urban agriculture semi-natural etc there it is in the right colors you can see here the legend and we have the catchment polygons in a previous video I've shown how to derive the catchments polygons from a digital elevation model here we are going to use these catchments to derive the percentages let's first change the style you can use the layer styling dock for that and let's make them transparent and let's make the stroke width a little bit thicker so we see the boarders so the idea is that for the aggregated land cover classes we get a percentage in each of these catchments sub Catron polygons let's first treat the catchment polygon file go to the attribute table and there we see five polygons and what we see there is that they all have the same number that's a result of the catchment delineation process and what I'm going to do first is replace the DN value with a unique number so I can do that by changing this to dollar ID that will generate for each polygon or unique numbers I do update all and now we get a unique number and I'm going to create a new column to calculate the catchment area call it catch area and that will be a decimal number don't make it a bit big we'll be in square meters and I want two decimals there it is and there's another internal function for that that is called tolar area that will calculate the area and make sure that you write it to the right column so catch area in our case and then I click update' all and here we see then the catchment area in square meters so I'm going to save this so the idea is now to intersect this one with the land use land cover classes from Kareem and then calculate the class area of the intersected result and make the proportion with the catchment area that will result in a percentage per class so there are a few more steps we need to do this map of course is too large and it's in the wrong projection if you hover your mouse over the layer you can see the file name of course or the database in this case and you see the epsg code 303 5 we need to be in 3 to 6 3 2 which is the UTM zone 32 north projection so you can do that in one step am I going clicking right and then choose export save features as and I'm going to choose the output name let's make it a shapefile and I call this Horine 2018 reprojected and here we can change the projection to the one of the project the UTM and i can change here the extent of the calculation and here we can choose calculate from layer or from the map canvas extent and i choose here the catchment polygon so the result will be only the boundary of our catchment polygons so we don't have too much data of the rest of europe in the calculation ok there it is now we can copy the style in this one and there we are so we can remove the original file and now our area is reduced to the polygons the next step is to aggregate the Corrine glasses that are now at level 3 to level 1 so go to the attribute table and we're going to edit and I'm going to calculate a new column and we are going to call this level 1 it's a whole number an integer and the length is one digit and now I'm going to make the equation here level 1 equals and now we need to use the expression dialog and there we use the case function case when and then the field code 18 here you see all the unique values if I click all unique so this one code 18 selected if H larger or equal to 100 and code 18 if you double click it automatically comes there is less than 200 then the result value is 1 and we can copy this line a few times and modify it smarter than 200 and less than 300 then we call it class number 2 here we do 300 to 400 class number 3 and here we do 400 to 500 class number four and we see that the it goes up to 511 512 so we can make the last line if its larger than 500 then five and you end the case function with and and the preview shows that we get some sensible result so click OK and that whole equation is filled in here level one equals and then that selection and our update all and I get here all the level so you can see that 112 is one the 312 is 3 and 512 is 5 save the file the next step is to dissolve in the land use classes because we can see that many polygons have now the same value class 1 class 2 class 3 and they need to be considered as one feature and to reduce this also the amount of features so I'm going to use the dissolve function for that factor geoprocessing tools dissolve as an input we use the Kareem reprojected file that we have and we're going to dissolve based on the level 1 field that means that everything with number 1 each polygon with number 1 will become one feature etc and we save the file Carine 2018 dissolved we're in it close and here we see the dissolve version so if I open attribute table then it should reduce to the five classes that we have and we can give it some random color categorized level 1s if I I'm not going to spend time on changing the colors now and here we see now the different patches in the polygons of the catchments and now what we need to do is to intersect the catchment polygons with the land use polygon so we can calculate the fraction or percentage within each catchment polygon therefore we use the intersect function vector geoprocessing tool intersection and what we are going to intersect is the Kareem data with the polygons so they are cut the classes will be cut into pieces based on the border of the catchment polygons now we keep all the fields and we save the output to Kareem catcher intersect it and then we run it and this is an error that relates to the geometry because of the catchment delineation there and the cell size there can be some geometry problems the best way to solve this is to before the intersection so if you get the error which you often will get you go to factor and the quick fix is to calculate a negative small buffer so the problem is the polygons of the catchment and we put the distance here at minus 0.001 we keep everything else as default and we save it to catch Olli buffer and we run it it's very quick close we can copy the style and we can remove what we don't need to not make mistakes and let's see if now the intersection will work go to the intersection and the input layer is the green dissolved and the overlay is catch poly buffer we keep all the fields to get all the attribute tables as well from the polygons of the catchments as from the land use land cover data set into the output file in which we go green catch intersected it made something previously but I was maybe not correct because of the error and then we run it now it doesn't give the error close and now what you will see is that we only have the land use land cover in the catchments so I can copy the style there it is and let's check the attribute table and what we see there is all the columns we find the catchment area and we find the idea of the catchment and the level 1 classification so what we now need to do is to add a column for the area of the class in each catchment so for each feature now that we have intersected we want to know the area so I add another column in a similar way with as we did before and I call this class area decimal length let's make it again ten with two decimals and what we do there is class area equals and now it's dollar area again but now it is of the classes within the catchment the intersect at once and I update and there we get the values and now the final step is to take the proportion and calculate the percentage so we can call this one percentage and we can do that with one decimal or two decimals then let's make it four and one decimal and then I can say percentage equals and then we can make the equation better to do it in the editor where we say that is the class area that is a bracket to the class area divided by the catchment area times 100 now here you see already a result for one class as an example do okay I'm going to update all and here you see the percentages each glass so if I select this one big one there is 58.1% of this catchment consists of that glass you shouldn't forget to save this whole file so now you can further process this in in Excel to make pie charts for example
Info
Channel: Hans van der Kwast
Views: 31,226
Rating: 4.9317074 out of 5
Keywords: QGIS, land use, land cover, catchments, polygons, dissolve, intersect
Id: xfjg_jpgiTE
Channel Id: undefined
Length: 17min 38sec (1058 seconds)
Published: Thu Feb 14 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.