You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This might be a bandaid, but you could insert some code to check for SpatialPolygons objects and convert them to SpatialPolygonsDataFrame objects on the fly. This chunk simply adds an attribute table (@data slot) with an ID column numbered 1:length(x).
# Function to convert SpatialPolygons to SpatialPolygonsDataFrame
makeSpatialPolygonsDataFrame <- function(x) {
x <- SpatialPolygonsDataFrame(x, data.frame(ID=1:length(x)), match.ID=FALSE)
return(x)
}
# Check for SpatialPolygons and convert if needed
if(class(x) == "SpatialPolygons") {
makeSpatialPolygonsDataFrame(x)
return(x)
}
srs.polygon
andsss.polygon
are not accepting a SpatialPolygons object, and aborts with an error. They both accept SpatialPolygonsDataFrame objects.The text was updated successfully, but these errors were encountered: