r - Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘overlay’ -


i trying use overlay function , code following:

usa <- map('state',boundary = false, lty=2,plot=false,fill=true) usa_sp <- map2spatialpolygons(usa, ids=usa$names, proj4string = crs("+proj=longlat"))  comb.dat <- read.csv("agbregion.csv",header=true) names(comb.dat) <- c("lon","lat","harvdb") names(agbyr)<- c("lon","lat","harvdb") names(agbdiff) <- c("lon","lat","harvdb")  pts <- spatialpoints(cbind(comb.dat$lon,comb.dat$lat)) ptsyr <- spatialpoints(cbind(agbyr$lon,agbyr$lat)) ptsdiff <- spatialpoints(cbind(agbdiff$lon,agbdiff$lat))  o <- overlay(pts, usa_sp) 

but got following error: error in (function (classes, fdef, mtable) : unable find inherited method function ‘overlay’ signature ‘"spatialpoints", "spatialpolygons"’

i don't know what's going on. explain me? lot.

see of ?raster::overlay. notice first few lines.

## s4 method signature 'raster,raster' overlay(x, y, ..., fun, filename="", recycle=true, forcefun=false)  ## s4 method signature 'raster,missing' overlay(x, y, ..., fun, filename="", unstack=true, forcefun=false) 

this tells method works on raster objects, such rasterlayer, rasterstack , on.

consider using sp::over, declared to

consistent spatial overlay points, grids , polygons: @ spatial locations of object x retrieves indexes or attributes spatial object y


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -