seattle <- spChFIDs(seattle.shp, paste("seattle.shp", row.names(seattle.shp), sep="."))
Results in this error:
Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘spChFIDs’ for signature ‘"SpatialPointsDataFrame", "character"’
I have tried raster::union; sp::merge, and rgeos::gUnion. None of which achieve what I want: The analogue of an ArcGIS merge.
library(raster) ?raster::union test<-union(phoenix.shp,seattle.shp) #Error in as.vector(x) : no method for coercing this S4 class to a vector #s4 class seems to have slots, accessed by the @ symbol. #This has both polygons and a dataframe. #all the R methods seems to deal with one or the other; not both. library(sp) ?sp::merge #Merge a Spatial object having a data.frame (i.e. merging of non-spatial attributes). test<-merge(phoenix.shp,seattle.shp) #only nets phoenix. test$GEOID10 slotNames(test) #"data" "coords.nrs" "coords" "bbox" "proj4string" test@data #1218+22 so just phoenix test@coords #just phoenix. library(rgeos) ?rgeos::gUnion test<-gUnion(phoenix.shp,seattle.shp) #So gUnion gives the topology, but not the dataframe. #do I hae an ID I can join the datafrmae back with? slotNames(test) #"coords" "bbox" "proj4string" test@coords plot(test)#both sets of points, no data.
If you need test data, download two counties worth from here