I am trying to reproduce the example posted on

Extracting intersection areas in R

Although, when I try to create the SpatialPolygon "p2", R returns the error: "Error in as.vector(x) : no method for coercing this S4 class to a vector".

Any suggestions why is it happening? How can I fix it?

  • The exampled worked perfectly for me. I suggest checking that all the needed libraries in the example were loaded without any problem!
    – Guzmán
    Feb 23 '17 at 18:08

The intersect function is masked. Try raster::intersect() instead of intersect().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.