Monday 18 June 2018

qgis - How to measure volume in raster?


There are many similar questions like this. But I haven't found a usefull answer yet. So I hope some of you have a suggestion to this.


I've done some flyovers with the drone at a contruction area, and then got a DSM out of these, using Pix4D. Now I have 2 different DSM, and then imported these into QGIS. Through rastercalculator i've withdrawn these from each other to get the height difference. See below:height difference



I then would like to find out the volume of where there have been a height difference.. So some of the area I have marked red (increased volume) and the blue (decrease in volume). Also using rastercalculator and polygonize. See below.


increased volume in the red area


decrease volume


Is there a smart way to find the volume of the blue and red marks of these rasterlayers in QGIS, or do any of you have an alternative program that would do the job easier and faster?



Answer



The best way I've found to do so is to use a combination of the raster calculator and zonal statistics.


You first need to calculate the difference between the two rasters, using a filter to get either the positive or the negative difference, and no values elsewhere. In Qgis calculator this would give something like :


((A-B)>0)*(A-B) To get the positive change


((A-B)<0)*(A-B)*-1 To get the negative change (multiply by -1 if you're interested in the absolute value of the change)


Once this is done, create a new vector layer, showing the zone of interest (blue + red, just avoid the places where you are not interested. As this is construction, you can probably select only the zones where you know there has been changes).



Then use the tool in Raster -> Zonal Statistics to read the sum of the values of all pixels within the vector layer. Do it twice, both for positive and negative change.


Multiply then the value obtained for each case with the size of your pixel squared, to get the total volume.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...