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

  • SEARCH
  • Home
  • 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 9158501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:15:41+00:00 2026-06-17T13:15:41+00:00

I am wondering if this is possible to do this R . I have

  • 0

I am wondering if this is possible to do this R .

I have one data as SpatialLinesDataFrame and another as spatialPolygonDataFrame. Is it possible to overlay these two data ?

When I try to overlay these I get the following error:

  jd <- overlay(res,hello) 
  Error in function (classes, fdef, mtable)  :  unable to find an inherited method for function      
  ‘overlay’ for signature ‘"SpatialLinesDataFrame", "SpatialPolygonsDataFrame"’

In the above code res is the SpatialLinesDataFrame and hello is SpatialPolygonDataFrame.

I have an shapefile and then I have data points with x,yand z
coordinates. I want to show the contour lines on the shapefile.

The procedure I used is using akima package to do the interpolation. The
code I used to interpolate is

fld <- interp(x,y,z)

Then I changed this to spatial object by using following code:

res <-ContourLines2SLDF(contourLines(fld))

The above command would store the contourlines as spatial data.

Then I read the shapefile and I plot both shapefile and res as follows:

p1 <-
spplot(hello,sp.layout=list(list("sp.lines",res)),col="blue",lwd=0,fill="grey",colorkey=F)
p1

“hello” is my shapefile and “res” is the object I created as shown above.

The problem is contour stored in “res” extends beyond the shapefile. So I
want to clip that contour with the shapefile and only display the contour
within the shapefile area.

So I am looking for a way to clip the contour layer with the polygon layer.

I have attached the image I got with my code.
enter image description here

In the image you can see the lines out of the shapefile. I also want to know
how can I display the contour levels on the map.

Thank you so much.

Jdbaba

I also want to know what does overlay does exactly. Does it intersect the area of both the data ?

Thank you.

  • 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-17T13:15:43+00:00Added an answer on June 17, 2026 at 1:15 pm

    It sounds like you’re trying to clip your lines to the polygon extent. Use gIntersection from the rgeos package. Here’s a reproducible example:

    library(rgeos)
    xx <- SpatialPoints(coords=matrix(data=c(0,0), nrow=1))
    xx <- gBuffer(spgeom=xx, width=1)
    yy <- SpatialLines(list(Lines(Line(matrix(c(-1,1,-1,1), nrow=2)), ID=1)))
    zz <- gIntersection(yy, xx)
    

    You can overlay the plot like so:

    plot(xx)
    plot(zz, add = TRUE, col = "blue")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if this was possible... I have a sequence of variables that
I'm wondering if the following is possible. I have a survey with 100+ questions,
I was wondering today if it was possible to transfer data from one database
I have two sets of data in this form: x | y | z
I'm wondering if iOS allows one to do the following: I have a puzzle
I'm wondering if it's possible to map different data types. For instance, I have
Say I have a file which contains one line of data formatted like this:
Is it possible to have more than one data type within an array list,
I was wondering if this was possible? I'm not familiar with using windows command
I was wondering if this was possible, and if so how I'd go about

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.