QGIS Part 2 - Graphical Modeler

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay so this is that part two of those two two um videos and this in this in this part i'm going to go ahead and show you how to create this modeler so the modeler allows you to add a number of different um algorithms and inputs to a almost like a flow a flowchart you build a flowchart with your algorithms and allows you to run a number of algorithms in series to get a particular output depending on what you need and in this case we are buffering various layers by different distances by different buffer distances we are then counting the number of points that intersect with that buffered feature and getting a result with the number of features with the number of trees and in this instance it's 49 259 trees that are intersecting with the footprint of the gigafactory so that's what we're going to do um if you're interested in that follow on and i'll show you how to do that in qgis okay so how do we go about that we have our layers we've got our random points which represent our trees and then we have our greater extent which is the land use now we don't we no longer need that because we only needed that layer to generate the the forestry or the forest or the trees and we've got our footprint and then we've got a greater extent uh which these two layers we can use to to calculate we can count points in a polygon but what i want to do is try and demonstrate how this graphical modeler works by linking a couple of algorithms together so that you don't have to go through the the series of of of doing them individually and taking a long time and when you have a model saved up you can just run the model and then repeat rinse and repeat okay so let's see let's see if we can get a handle on this modeler so under the processing menu we want to select graphical modeler and mine has popped up onto my second screen so i'm just going to minimize that and drag it across and this is what it looks like so essentially what we're going to do is we're going to add information and algorithms to this sheet this blank sheet here which will create a flowchart effectively and will execute the various algorithms and functions when we want them to so let's use an example of okay we'll add a layer so first of all we've got inputs and algorithms so let's label this one we're going to label the model first of all and what should we call it we are counting trees we can go giga trees giga trees okay and group now this is not important uh no group okay so we're going to add a vector layer and the vector layer we're going to add will then allow us to choose the vector layer to work with so we're going to go drag that icon across there and then it pops up with a parameter name and we'll just call it just call it layer and it's going to be a polygon we'll say okay so now there we go we've got a layer added to our project now let's say we want to run an algorithm on this so let's choose buffer we're going to choose to buffer something and here is the the list of buffer algorithms and options you can buffer rasters and all sorts i'm going to just go with the box standard one for the vector geometry drag that one in and then it's going to pop up with the the various options so it's called buffer that's fine input layer there is only one so that's fine we're going to say layer and now this is where we can set the distance so we can set the distance to 100 let's call it segments we'll make it 10 all this other stuff is fine we are going to dissolve the results yes and then this final option allows you to output the result to your project or to not output it to be used in the next algorithm so we are going to output it to our project for this first example so we'll just call it result uh whoops let's call it result buffer and then say okay and there we go so now it links them so now it knows that there's a there's a there's an expected input and it's going to be buffered with those settings that we chose which were a buffer of 100 meters segments 10 and you can change the other settings here and then it's going to output the result to the project okay so let's start off by running it so you click on this little run mode or we click on f5 and let's see what happens okay so it's asking us for a layer so we're going to start by buffering the footprint so it's looking for the input and the result buffer is going to create a temporary layer which will just be added to our project so let's run that and close and there it is okay so it's buffered the footprint by a hundred meters very simple now that you can do using your ordinary menus so there's no point doing that in a in a modeler because you can do it 100 times and just adjust when you need to the usefulness comes when you need to link it to other stuff so let's remove this layer and go back to our modeler so what do we want to do the objective here is to be able to change buffer distances to determine what a different buffer will how a different buffer will affect the number of trees which need to be removed from a site okay so essentially we are counting points in a polygon and we have got a buffer that needs to be adjustable so let's start out by adjusting the layer so we are going to go back to inputs and we want to add a number so the number option will drag that in and the number this will just be buffer distance but for distance the minimum value can be zero maximum value let's go 500 meters there won't be a default value uh float let's just go integer and then say okay okay so now we've got this value in our model but it's not being applied to anything yet so we need to start editing the the buffer algorithm again so you click on these little uh ellipsis or what do you call these little three dots to edit that little algorithm and now the distance is no longer 100 it's going to be editable so you click on this button and we're going to go for model input and then there's only one option because there's only one number input value which is buffer distance if there were a couple you would need to click on the drop down arrow and select it so now we are able to select that so let's see what that has the effect of doing to our model so we'll say okay and let's run that model and then it starts off with a distance okay what do you want to buffer by we did 100 last time so let's do 200 this time and then you still get the option to choose your layer and create a temporary result so we'll run that and close so there we go so that is the effect of 200 meters okay so editing and adding that uh that value that number value allowed us to change that or we'll have the option when we input that layer or that value into our buffer let's remove this and go back to our graphic modeler so so essentially what you will do is when you start creating a model you may have only a couple algorithms and inputs at first and then as you find tune it you might find you start adding a whole lot of other steps to your model to improve it and that's that's pretty much what we are doing now okay so the next thing i'm going to do is i want that buffer i want to be able to only buffer selected features so there is an option an algorithm if we call selected features so it's uh selected features let's zoom off a bit yeah extract selected features okay so now the reason i want to do this is i want to be able to to select a feature and then only buffer that feature and and then that'll that'll just give us a bit more versatility going forward so let's add extract selected features to the model description extractor selected features and it's the input layer yes yes yes and then selected features enter name of final result now that's fine so we can say okay and now what we need to do is change the buffer from input layer to selected features okay and you'll see how this changes the flow so now we can put that there this here and let's see what this does so we'll run that okay first of all before we run it let's go and select one of the features so let's select let's say we just want to buffer this out building so we've selected it and then we'll go back to our model and run it and make it 200 and it's going to be the footprint so if we selected extent it wouldn't work because we haven't selected anything so make sure that you do select the correct feature in the relevant layer and then we can just select run again okay so now having added that option to extract the selected features it only buffers that selected features feature okay so what is next let's just remove this first of all i always like to remove my temporary layers otherwise my model and my project gets very messy my project at least and my table of contents or layers panel gets very messy so let's go back to the modeler okay so what's next we've selected features we've got a buffer distance set now the next thing is we want to count points in a polygon so this option can actually be removed because we are going to use the output and then run another algorithm using that output so we're not going to add it to the final project but the count points in a polygon that will be added to the next product so let's go count and let's see if we can find it count points in polygon so that is the one we want to add okay here we go so the description count points in polygon we can call count trees if we want to and then the input layer is going to be the buffered algorithm okay the weight field that we're not going to set we're not going to set a class field but the output field that comes or gets added to the the output layer we can call trees and yeah let's go results we're going to go um number of trees or we can just go results let's just call it result the result okay all right so now it's getting pretty messy so now that's not right i don't think that's right let's let's just double check that oh points we need to select points okay so that's why it's not right so i need to add another layer over here and we can go layer vector layer and this is going to be uh i want to go tree select uh choose to count and there's a point okay now if we go in here i need to make sure i set the points as trees to count here we go that looks better okay now when we run it we're going to get an option to select this layer now of course we don't have to um add an option to to add a vector layer you could go straight in here or if we cancel this you could go straight in here and then click on this little radio button and go and permanently always use a particular layer so you could go and select trees in having this this variable in your model it just allows you to choose a different point file if necessary so maybe in our example because there is only one point file this little variable option here is superfluous but let's leave it for now and run and see what happens okay so the buffer distance we're going to go 100 so a buffer distance of 100 the input layer is we're going to use oh hang on a second oh there we're going to select that one let's select both of them so let's try that again okay so let's run that okay so distance of 100 now the selected layer is going to be both of those features and then the trees to count random points and it's going to create a temporary layer so let's run that and that is what we expect to see it's a buffered feature which will now have a column in the attribute table with a trees and the number of trees that intersect with that new shape so we can double check that that's 94 753 trees so what we can do if we want to double check that is let's use this vector research tools we'll select by location we want to select random points that intersect with result and create new selection let's run that and close and now if we open up the attribute table no it's not that one sorry we open up the attribute tab for random points it should be uh 94 000 odd trees selected that's what i'm expecting to see let's just click ok we're waiting for it to open okay there it's opened let's make this a bit bigger there we go 94 753 so what it what i did is i i did the exact same thing essentially by selecting using this shape i was able to isolate all the trees that intersected with it and the number is the same so you can do that just to double check that your model is working correctly okay so there we go we've got a model that is working and we can tweak this further this is one nice feature that i'd like to show you and that is how to add a style to a model so let's minimize this for now and what i want to do is i'm going to open the properties and i am going to change the color the full color what should we make it like a purple like a sort of a transparent purple something like that okay and then the outside line will make one and so let's leave it black okay then but for labels i want to go single labels i'm going to label on trees draw text buffer and where is the option i actually want to let's just change this it's going to be trees but it's going to be number i'm going to use the hashtag number number of trees well it doesn't like that concatenate oh it doesn't like that only one concatenate so that's my expected result from that little equation there so number of trees okay we'll say okay and apply and okay and that's what it's going to look like bearing in mind that this is for the entire area because we selected both of these features when we ran that result okay so now what i'm going to do is go to properties and i'm going to save the style so i want to say save style and put it in my folder and i'll just call it style save and okay and okay okay so now we can delete that remove layer yep and let's just deselect that for now we'll go back to our model yikes where's my model gone i think i've panned off the page here yes there it is okay so i just panned too far for some reason uh yeah so i might have just clicked and panned but anyway i mean your model can get gigantic but if you can't see all of it it might be confusing anyway i'm currently in the top left-hand corner of this page all right so let's add a algorithm for the style so i'm going to type in style and there's set style for vector layer that's the one i want set style for vector layer is the name that can be fine and i'm setting the style for the count trees and then i want to load a style okay so i am going to actually select a style from my hard drive by selecting on that ellipsis takes me straight to that folder select the style.qml say okay and that's where i expect to see it so it's count trees result okay so let's see how that works so i'm going to drag this onto my second screen i'm going to select the extent this time let's select the extent and then if i go to my browser oh you should have let's just refresh this where's my models i think i need to save it first so let's save this we're going to stick it under projects yeah i don't want to stick it there i'm going to go desktop gigafactory projects and what is this count trees save there we go so now i can drag this off to my second screen here and if i refresh i don't need to there it is so there is my model in my browser so under projects where i will project where i saved it there's giga trees so now i can run it from here so just double click on it there and it runs your model so you don't have to have that model window open all the time once you've finalized it you can just run it from your browser so let's go with um 250 meters we are using extent this time the trees and let's run it and close back to layers and there we can see the style has been set so it's loaded the style that we created let's set the 200 meter buffer on and the number of trees that intersect 364 fifty one trees are affected by this version of the model let's just play with that a bit more remove that layer deselect uh deselect okay let's go with the footprint okay with the current footprint let's say we don't we're assuming that there's no setback line so no buffer so we just want to buffer the the gigafactory we're not interested in this shape and we're assuming there's no buffer so i'll just leave it at zero trees to count random points run close 49 259 trees or points in a polygon and that's how you can create a fairly useful model and you'll see now um if i just want to adjust the the buffer distance and just run that model over and over it it's a lot quicker than running through each of those steps each time and you can build on this you can do something with your with your with your results and your outputs and you can keep going okay that's how you use the modeler we used it to determine how many trees were within a certain distance of the gigafactory footprint and you can use it for for your own study any of your own features i hope you've enjoyed the video we'll see you next time cheers
Info
Channel: Q-tips
Views: 859
Rating: undefined out of 5
Keywords: QGIS, QGIS Graphical Modeler, GIS Modeler, Count points in polygon, QGIS Buffer, QGIS styling panel, Giga Berlin, Gigafactory Berlin, Tesla, Tesla Gigafactory, Gigafactory footprint, Gigafactory environmental
Id: fjxJwMSp0K4
Channel Id: undefined
Length: 21min 17sec (1277 seconds)
Published: Sun Mar 07 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.