Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9206723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:14:09+00:00 2026-06-18T00:14:09+00:00

I need to find the volume from the surface down to a specific contour

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:14:10+00:00Added an answer on June 18, 2026 at 12:14 am

    Function contour just draw the contour lines but doesn’t return any values. What you need to use is function contourLines.

    cL <- contourLines(x,y,volcano)
    

    From there, you can calculate the area of each contour lines the following way:

    area <- rep(0,length(cL))
    for(i in 1:length(cL)){
        d <- data.frame(cL[[i]]$x,cL[[i]]$y)
        sa <- sb <- 0
        for(j in 1:(nrow(d)-1)){
            sa <- sa+d[j,1]*d[j+1,2]
            sb <- sb+d[j,2]*d[j+1,1]
            }
        area[i] <- abs((sa-sb)/2)
        }
    area
    [1] 1.413924e+05 3.109685e+04 2.431528e+04 2.049473e+04 6.705976e+04 3.202145e+05 1.720469e+03
    [8] 2.926802e+05 2.335421e+05 1.834791e+05 1.326162e+05 4.672784e+02 9.419792e+04 5.121851e+03
    [15] 5.126860e+04 3.660862e-01 1.216750e+03 2.051307e+04 4.670745e+02 4.146927e+03
    

    Now, if you want the volume between two contour lines (say between levels 120 and 130):

    level1 <- 120
    level2 <- 130
    levels <- unlist(lapply(cL,function(x)x$level))
    base <- (1:length(cL))[level==level1]
    top <- (1:length(cL))[level==level2]
    vol <- (level[top]-level[base])*(area[base]+area[top])/2
    vol
    [1] 2631111
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I find div that contains specific text and delete this text from
This is a very basic problem, I need to find the area and volume
I need to find a way to get the current audio output volume while
Need to find the timestamp for the first minute of the first day of
I need to find a flexible solution for access control in PHP. In the
i need to find out automationid for key board values? how to send keystrokes
I need to find all the occurences of a file Test.TXT in c:\ or
I need to find the coordinates of windows open even when they are not
I need to find a silence in a mp3 file. Simple as that. For
I need to find out the value passed into an indexer. My code (c#)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.