0

I am trying to plot 3 different spatial data frames on top of one another - so far - only the first two have worked - pts on bndry

Whenever I add polygon() to the mix, I get the following error:

> plot(bndry, xlim = c(590900, 595900), ylim = c(4785786, 4793200))
> points(pts, col=colcode, pch=16)
> polygon(polys)


Error in as.double(y) : 
  cannot coerce type 'S4' to vector of type 'double'

To be sure, pts and polys are projected in the exact same CRS:

> polys@proj4string
CRS arguments:
 +init=epsg:32617 +proj=utm +zone=17 +datum=WGS84 +units=m
+no_defs +ellps=WGS84 +towgs84=0,0,0 
> pts@proj4string
CRS arguments:
 +init=epsg:32617 +proj=utm +zone=17 +datum=WGS84 +units=m
+no_defs +ellps=WGS84 +towgs84=0,0,0 

Is there a reason for this and a known workaround for this error ?

iskandarblue
  • 7,208
  • 15
  • 60
  • 130
  • 1
    Please make this a [reproducible question](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Not knowing what `bndry`, `pts`, or (perhaps most importantly here) `polys` look like, it's all speculation. – r2evans Mar 13 '17 at 22:19
  • 3
    Next point: I don't think `polygon()` has a method for type `SpatialPolygons` (assumption). Perhaps `plot(polys, add = TRUE)` would work instead? – r2evans Mar 13 '17 at 22:23

0 Answers0