I need to find the volume from the surface down to a specific contour in R. Taking the contour example from the R help files:
x <- 10*1:nrow(volcano)
y <- 10*1:ncol(volcano)
contour(x,y,volcano)
given the resulting graph, how do I find the volume from a specific contour line up to the surface.
In practice, I will use bkde2D to get a density map for a scatter plot. From this I can make the contour plot, but I would like to determine the volume defined by various density cutoffs in the resulting plot.
Function
contourjust draw the contour lines but doesn’t return any values. What you need to use is functioncontourLines.From there, you can calculate the area of each contour lines the following way:
Now, if you want the volume between two contour lines (say between levels 120 and 130):
And that’s as far as I can go because I don’t see how to proceed if the next contour line is split into several sectors.