Volume Calculations using QGIS

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone welcome back to the channel in this video we will go through a case of calculating a volume of a pit like this and a small hill like this below and above a specified base level now I'm going to spend relatively a bit more time explaining the methods and tools for this for the case of the pit and once you have properly understood the concept it just becomes a matter of Performing the same steps for the heel to calculate its volume when it comes to that so before we get started let's have a look at the data sets that we're going to deal with today and right over here you can see two rasters one is called pit. Tiff and the other one is called hill. Tiff so it's pretty self-explanatory which raster data set refers to what so what I'm going to do is I'm just going to drag this pit. Tiff raster onto my workpace like this and as you can see over here this is the default color ramp that gets assigned and what it shows is basically how the Elation values vary over this region and you can clearly see a drop in the elevation values right over here if you if you refer back to the original elevation values from this color ramp now just for visualization purposes if I were to go ahead and change this color ramp to be something a bit more interesting what we can do is we can click right over here we'll double click in fact and under render type let's go ahead and switch this to single band pseudo color and from here you actually have the choice to choose quite a number of uh different color Rams and in my case I'm just going to go with this uh turbo color ramp which is basically what has been assigned automatically as soon as I switch to single band pseudo color and click apply and okay and from here you can see how each of these colors have been assigned to different uh elevation values and if you refer back to the actual values you can see that it ranges from basically around 0.79 all the way up to about 46 41.6 and this reddish areas basically refer to this high elevations and if you refer to this blue color area you can clearly see the extent of this pit which is shown in this bluish colors and to make things a bit more interesting and easy what I'm going to do is I'm also going to create a contour map using this roster and with a contour map like that it would be quite uh easy for us to visualize how this illation changes because that's basically what a contour map shows us areas with same Elation basically connected together with continuous lines so to create a contour map from a raster like this it's actually going to be quite easy if you head over to processing and select the processing toolbox from here we can simply search for contour and under gal you can see that there's one tool called Contour so the inputs for this are going to be well it's going to generate the Contours based on this given rust so it's automatically selected and something quite important is the contour interval that we have to specify so by looking at this elevation range which is varying from 0.7 to 41.6 I'm just going to fix a contour interval of about maybe 5 m but this is completely up to you and it'll really depend on your specific uh case and we don't really have to save this Contour file into a permanent file so I'm just going to let it create a temporary file and after that just go ahead and click run and you can see how the contour map got generated I could uh open up the symbology tab again and maybe change the colors instead of letting it be a very light yellow color like this I'm just going to specify a dark color like this so that the contour lines would be much more apparent for us like this and in addition to that if I would just right click and open up the attributes table of these Contours the newly generated Contour shape file you'll see that uh there you can see that there are three fields or three columns in which this is the one that I'm actually interested in which shows me the exact elevation values so in order to bring these elevation values as labels that are tied to each of these different contour lines what I'm going to do is I'm just going to right click over here and go to properties and if you switch over to this labels tab you can go ahead and select single labels from here and specify that you would like to display the labels which are under this e column which basically refers to the elevation do a slight adjustment to the size and after that click apply and click okay and now you can clearly see what each of these different contour line is supposed to represent now defining the outer boundary of the pit well that's something that you have to actually think about and in this particular case I'm just going to make use of a 3D representation of this roster to specify sort of of the boundary or the outer boundary of my pit and to do that I'm going to make use of an external plug-in called qgis 2 3js exporter which is uh not something that I'm going to discuss in this tutorial because I'm doing this just for the visualization purposes in case if you guys are not really familiar with using this plug-in you can just follow along because I'm doing this only to sort of visualize so that we could clearly see how this raster looks in a bit of a 3D manner so once you open up this qjs to 3js exporter uh I can just click right over here to select the pit and and even after I zoom it in uh I might not really see how the elevations change uh just because of the scale so what I'm going to do is I'm just going to head over to scene settings and change the vertical exaggeration to be about 30 so we just exaggerating the elevation values vertically so that I would be able to see clearly what sort of a contour line I could use as the outer boundary of the pit and as you can see I think we could either use 25 or 30 as the contour line which represents the outer boundary of our pit and just for the purposes of this tutorial I'm going to stick with this contour line which corresponds to 25 M and I'm going to pick that to be my sort of outer boundary of the pit and what I'm going to do is I'm going to calculate the volumes that are sort of below that 25 M uh elevation all right so let's get rid of this uh 3D View for the time being or in addition if you would like to digitize and create your own boundary in order to specify the outer border of the pit well you could simply do that as well there's nothing that's sort of restricting you in doing that however since one of the tasks that we are supposed to do is to specify a base level below which we are going to calculate the the volume of this bit uh it's essential that we pick that base level that we're looking for and I think 25 M be a good pick in this particular case and given that we have already established that 25 M is going to be our base level the next step is to basically calculate the volume using a tool that's inbuilt and that's called raster surface volume you will be able to see under raster analysis raster surface volume tool just double click on that and again our input layer is going to be this raster and over here we have to specify that basee level that we discussed about so I'm going to enter 25 over here and when it comes to the method what we are going to do is we're going to count only below the base level just stressing the fact again that what we trying to do over here is to calculate the volume of a pit which is basically extending downwards from this specified base level and the results of this exercise is generated as a report so even though it's optional what I'm going to do is I'm going to save this report to a file at a nonn location so let's uh browse to my working folder and I'm going to name this as a volume report and as you can see over here the file type it's going to get saved as HTML file which means you're going to use one of your web browsers to basically open that up so click save and after that we can go ahead and run this tool and you can see that immediately it managed to generate that report right over here so if I click on this link you can see right over here the corresponding details and we have the volume to be 30, 310,000 1800 M well if you wish to do a quick check what you could do is you could use one of the tools that's available to see whether this calculated area is correct or not if I were to use this tool right over here which is this measure area tool just make sure that you are measuring the area and set the units to be in square meters and after that what we can do is we can just roughly draw along this perimeter of this 25 M contour line it's not going to be exact but it's going to give us a rough estimation of the area and we can compare that against the result that actually got generated and make sure that everything is in order so if I complete my circuit uh you can see that the area that gets recorded right over here is about 3,535 597 which is a pretty close value to this value I would say of course I'm going to trust this value more than what I did by my hand manually because this area calculation is going to be much more accurate since the calculation was done automatically so guys that's about it if you would like to maybe export this contour line which corresponds to 25 M into a separate polygon shape file you could actually do that as well simply by heading over [Music] to this polygonize tool which is under Vector geometry and you can select this Contour shape file and before we do that uh we need to select the corresponding contour line that we would like to export as a polygon so you can do that by heading over to the attributes table of that particular shape file and the one that corresponds to 25 M is supposed to be this line so I'm just going to select it like this and even if I close this window the selection is going to still remain and after that I'm going to open up this polygonize tool again and make sure that my input lay is going to be this Contours shape file and I'm going to generate or I'm going to polygonize only the selected features not all the features that are present in this shape file so in this case if I just go ahead and put the tick right over here it's just going to polygonize only the selected feature and none of the other polyline features and and let's go ahead and save this to a file as well I'm going to name this as pit uh extend and after that click run and now you can see that the extent of the pit gets demarcated beautifully like this by a polygon and now we can go ahead and uh deselect all the selections that we have done and what I could do is I could maybe get rid of the fill color of this and just have the outline so that it'll be much more clear that uh what we're trying to demaret by this polygon boundary is basically what we considered to be the outer extent of this pit and this calculated volume in cubic meters basically refers to the volume that is contained by this polygon boundary now that would be the quick and easy way of doing things however in order to make sure that we have arrived at the correct uh solution what I'm going to do is I'm also going to perform this volume calculation in a bit of a manual way which involves a number of uh different steps it's nothing complex but instead of just using one single tool to generate this volume we're also going to make use of the raster calculator in order to perform a couple of tasks manually and I'm trying to see whether I could arrive at the same number that we got right over here by following that couple of steps so let's do that before we head over to the next part which is calculating the volume of a small hill so as the very first step I'm just going to get rid of these unwanted parts of my raster simply by performing a very simple clip operation on this roster by heading over to raster and from here go to extraction and I'm going to select clip raster by mask layer and my input layer is going to be this raster of course and my mask layer is going to be this pit extent because now I'm just going to cut this raster by the extent of this pit and just only going to retain the areas that's going to be relevant for my calculation I'm also going to select uh cap resolution of the input Ruster just to be sure and after that uh click run and now you can see that we have a new rust that got generated which basically corresponds to the area that we need to calculate the volume for and in the first instance you can see that the colors that has been assigned to that doesn't really look that pretty so I'm just going to D activate this for the time being and basically head over to the symbology panel again and from here select single band suda color and just make sure that you have a bit of a color variation like this so that you would be able to quite easily visualize how this bit looks in this kind of a manner and now if you just have a look at uh the the elevation values you can see that still the lowest is going to be 0.79 and the highest in this case is going to be 24.9 all of these values are basically supposed to be below 25 M because that's the elevision value that we identified to be the base level below which our entire pit is going to lie and if I zoom in just a little bit now you can actually start seeing the individual pixels now if you're really curious about the resolution of this roster well what you could do is you could right click and go to properties and if you go to information right over here you can see the pixel size and it shows that the pixel size is 10 m x 10 m and you could even actually measure it manually if you were to zoom in until you start seeing these individual pixels and if you head over to this measuring tool and pick measure line and if you just simply draw a line from one corner of the pixel to the other you would be able to see that it's roughly about 10 m isn't it so it basically adds up uh to what we saw under the information of this particular roster and may I remind you again that what each of this pixel of this raster is showing us is basically the elevation value and if you're somehow able to make this raster show the volume of each of these pixels instead of elevation and if you just perform a sum operation over all of those pixels that should basically give us the total volume as well isn't it let me quickly illustrate that to you graphically as well so we establish the fact that we selected our base level to be 25 M and let's assume that we're looking at a cross-section of our pit like this so I'm going to mark this level to be 25 M and now just imagine that we looking at one single Pixel which shows maybe a pixel value of about 19 M and in this diagram let's imagine that that pixel looks something like this where the pixel value is 19 M as I said as an example so if I were to assume the depth at that particular point to be a value called y then we can very easily see that the value of that Y is going to be the base height that we specified which was 25 M minus the pixel value of 19 M so if I were to write an expression for that y it's going to be like this Y is equal to the specified base height minus the pixel value and that's going to be 25 - 19 in this case and you could perform a similar task to maybe another pixel which shows an elevation value of around 15 m and in this case if you were to assume the depth to be a value of x then as you can see that x value is going to be 25 - 15 and now what if you wanted to convert this depth into a volume as I showed you guys we know that each of these pixels are of size 10 m x 10 m M so if I were to just multiply this depth by its surface area it's going to give me the volume so for an example if I were to consider the area aspect of each of these GD cell as well it's going to look something like this where the surface area is going to be 10 m by 10 m which means if I were to just take this pixel and multiply its depth which in this case is 6 M by its area it's going to basically give me the volume of that one single Pixel and if I were to plug in the numbers for this specific example of uh this y value so the depth is going to be 25 - 19 which is six and that depth is going to get multiplied by 10 m by 10 m and that's going to give us the volume in cubic M So based on that analogy you can clearly see that if you were to generate a new raster which shows us the individual pixel volumes that's forming this entire pit we could just simply add them all up in order to just come up with the volume and to do that what I'm going to do is I'm going to head over to raster and I'm going to open up the raster calculator So based on the sample calculation that I showed you guys if you were to just come up with an expression to calculate the volume you can imagine that the volume is going to be measured if you were to multiply the depth of each pixel by its area and when it comes to depth the way to calculate the depth would be to take the base height which are in which in our case is going to be 25 M and we are going to minus out all the pixel values corresponding to this raster and after that what we're supposed to do is basically multiply that by the area which in this case is going to be 10 multiplied by 10 and of course I'm going to get rid of this part since I just wrote it to explain to you guys what we supposed to do so we not really supposed to have random notes in our expression box and over here when it comes to base height again we need to specify the actual value rather than uh leaving that to be just BH so base height is 25 and as soon as we do that you can see that it immediately recognizes that the expression is a valid expression and after that uh we're going to save this into a new file and I'm going to call that pit volume which is going to get saved as a Goot file as you can see over here so now go ahead and click okay and now if you were to look at these values you will start seeing a completely different range of values because now in this raster what we see is basically well each individual pixel is not really showing the depth but it's showing the volume so what we could do is maybe just for visualization purposes we could just again open up the symbology and change the color ramp to be this this apply and from here you can basically see how the volume varies and if you'd like to check the individual pixel values you could even do something like that by uh picking this identify features tool and if you right click on one of these pixels and select that you're referring to this pit volume roster right over here you would be able to see the volume value which is 1,9 61.5 cubic M so now each of these pixels are showing the volume values in cubic meters and it makes sense as well as you can see uh as we go into these deeper areas we're talking about much larger depths which means much larger volumes as well so you can see these areas in dark colors which basically refers to higher volumes compared to these edges that you can see right over here in this light blue colors and now all we have to do is since we have this shape file of this uh pit extent which we generated just a couple of steps ago if I were to deactivate both of these you could see this shape file which we have right over here and since we have such a shape file as our boundary what we could do is we could simply do a zonal statistics operation on this and you could get to that tool by searching for zonal Statistics over here and under rust analysis you could see the zonal statistics tool right over here click on that and now you input layer is going to be this pit extent shape file and the corresponding raster layer is going to be this pit volume layer and something quite important right over here now which statistic are we going to calculate so definitely what we need to do is we need to sum up the value of all of these uh pixels that are sort of bounded by this shape file so we definitely need to have some right over here selected and additionally if you would like to see how many pixels got added up together you could even select this count and things like mean wouldn't really make any sense for us to have in this particular case and as you can see there are so many different statistics that you can actually select but in this uh in this particular case since you're trying to sort of sum up all these uh volume pixels in order to obtain the total volume of the pit the sum statistic is basically what I'm after just going to leave this count uh ticked on as well just out of Interest well after that click okay and just click run over here and right over here you can see that it generated a new polygon called zonal statistics right click and if you were to inspect the attributes table now you could see the sum which means how many pixels got added up together in order to arrive at this value which is the summation of all the pixels of all the volume pixels which happens to be 30, 310,000 eight and in this case the pixel count was was 34,9 73 if you were to actually compare the volumes you can see that there's no drastic difference between the values where this one shows 30, 310,000 952 so it's almost it's it's basically pretty much there and both of these values are in cubic meters so guys with that I think you got the basic idea of calculating the volume of this kind of a pit using qgis and you could basically use the same steps in order to calculate the volume of basically anything it doesn't necessarily have to be a pit if you're talking about maybe an elevation that sort of popping above the ground and if you would like to calculate the volume of that mass instead of doing it below a certain base height you could do that as well and that's exactly what I'm going to do next since I have another file called this hill if I were to drag that and drop it over here and let's zoom into that so right over here if you were to look at this elevation values you can see that we have these lowest elevations to be 31.3 and the highest to be about 88 M over here so if I if I were to draw or if I were to generate the contour lines by heading over to this uh Contour tool and in this case I'm just going to specify the interval to be about 5 m and let's run this and if I were to check the Contour value of this line I could simply pick this uh identify features tool come back to this line and right click and make sure that I'm selecting Contour and right over here you can read the value to be 45 M and in this case if I were to calculate the volume of the mass that's sort of sticking above a base height of 45 M what I could do is I could simply open up this roster surface volume tool and input my roster which is going to be this hill and in this case the base level is going to be this 45 M and now what it's going to do it's going to calculate basically everything above the base level as I'm going to select right over here and let's save that to let's save that report to a permanent file as well I'm going to name it as Hill volume report save and then run and right over here you can see that volume report and as you can see over here this is the the volume of that particular hill before I wrap up the tutorial if I were to quickly show you guys in a a bit of a 3D manner what I refer to by the heel volume well let's quickly go ahead and change the color Ram to be something a bit more interesting just going to head over to this catalog and pick something from this uh topography selection maybe something like this and click okay and after that I'm going to open up that plugin that I was talking about which you guys don't really have to bother about in this particular tutorial as you can see over here the elevision line that I selected to be 45 is basically this contour line so what we calculate is basically the volume of this land mass above that contour line and I hope that it's clear for you guys by now so with that we are going to wrap up this tutorial if you do have any questions about the steps that we followed in this tutorial add a comment down below and I'll get back to you as soon as possible if not you can always show your support by hitting that like button and if you'd like to stay tuned for interesting GIS related tutorials like this don't forget to subscribe to this channel as well I'll catch you guys again with another tutorial soon
Info
Channel: GeoDelta Labs
Views: 6,779
Rating: undefined out of 5
Keywords: QGIS, GIS, VolumeCalculation, RasterAnalysis, TerrainAnalysis, Geospatial, QGISTutorial, VolumeTutorial, ElevationAnalysis, ZonalStatistics
Id: MUFeGhLbPKI
Channel Id: undefined
Length: 28min 38sec (1718 seconds)
Published: Sat Oct 21 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.