the -Sunit controls the unit in the plane; default is meter (-Se). Area calculated will then be in m^2. Correct?
-Z only deals with the vertical. Assuming a grid in meter, -Z0.001 would change the vertical units used in the calculator to kilometers. Correct?
If using -Z, one should be careful to use a corresponding -S. E.g. -Z0.001 should encourage use of -Sk. Correct?
-C: Why isn’t it a corresponding -Crlow/high/delta (Note the r) as there is for -C (``-Clow/high/delta`)?
The docs notes that -Crcval calculates the outside volume. So does -Crlow/high. Correct? I would like to add a note about his so that it is clear that all uses of -Cr will give an outside volume.
If you omit -C, what does the output mean? it is interpreted to mean -C0. But I get different results - ever so slightly - but why?
Only area is calculated (the area for all cells), since no z-value given, I assume.
# make very simple grid of a sloping surface
$ gmt grdmath -I1 -R-100/100/-100/100 X = tri.nc
$ gmt grdvolume -C0 tri.nc
0 19999.96 999996.020931 49.9999010464
$ gmt grdvolume tri.nc
0 40000 0 0
area of 40000 is obviously equvalent to 200x200 (the grid area), volume of 4000000 is obviously equivalent to 200x200x100 which is nonsenseactually absolutely correct. Surface area seems wrong on the other hand.
.
I tried to calculate area manually using grdgradient and grdmath:
gmt grdgradient tri.nc -Gtri_grad.nc -A270
gmt grdmath tri_grad.nc AREA ATAN COS DIV SUM = tri_area_SUM.nc
gmt grdinfo tri_area_SUM.nc | grep v_min
tri_area_SUM.nc: v_min: 56898.3476562 v_max: 56898.3476562 name: z
not sure that I have calculated correctly, but at least the area of 56898 is close to manual area calculations 200x200/cos(45 degrees) = 56568.542494924
Thanks both of you for answering.
This is meant to be as-easy-as-possible, so cartesian it is.
I made this simple plot of a constant sloping surface to do some mental work trying to figure this out.
Notes
feels like I’m practising elementery school maths - and failing.
grdvolume doesn’t take into account the slope This does not matter for the volume calculation, since the ‘area of the hypotenuse’ does not matter - it’s the area of the cross section that is important.
Calcluating the area and volume with help from the plot and checking with grdvolume
Count the colored squares to get the cross section area used for volume calculation
I think I understand -Cr[..], and it’s intuitively and geometrically easy to understand the results.
The small lowermost blue triangle is A = base x height = 2.5 x 2.5 / 2 = 3.125. Multiply by length, which is 20, to get the volume: V = A x length = 3.125 x 20 = 62.5. With grdvolume:
Now lets take the big red one, now using -C. This is more awkward as you have to specify a delta. I don’t want to specify any delta, I just want to know the volume between contours 0 and -5. This is exactly as big as the big blue one, so I would expect the exact same volume (V = 750) with the same reasoning as above. However, I get this:
I may have time to look at this at some point (my time is pretty restricted). But obviously this is a good opportunity to add some more test scripts for grdvolume and ensure any bugs or “features” are fixed.
Andreas, I think you need to replace * in arithmetic expressions with something or use it between the quotes. Otherwise * results in some font formatting change like changing from upright to italic. It is possible to understand anyway but best to have all the expressions written clearly.
the volume seems correct: (200*200*200*1/2 = 4000000)
while the surface area is not correct (39999.9603271 approx equal to 200*200 which is simply the grid area) meaning slope is not taken into account. relationship area*average height = volume holds: 39999.9603271 * 99.9999008179 equals exactly to 3999992.06543. This does not make much sense to me, these average height and area values, as long as the area is wrong (unless there is another elementary mistake of mine).
Interesting spotting that the volume (by the looks of it; since it equals exactly the number) is computed by taking area x (volume / area). I guess this will work fine when dealing with a simple artifical grid like the one I created, but must surely fail when you have an irregular surface (e.g. real tpopgraphy)…?
I thought this was done in a more robust way, according to the docs; volume integration.
So the docs actually reads like grdvolume has never been supposed to calculate surface area correctly.
Rather, it calculates the correct volume, as it says in the docs. then divides it with the grid area and also provides the “maximal mean height”. I kind of don’t understand the meaning of the “maximal mean height” calculated this way but that’s a different issue.