Skip to content
Prev 11799 / 29559 Next

merging several shapefiles into one

On Wed, May 25, 2011 at 8:06 AM, Nicolas Degallier
<nicolas.degallier at ird.fr> wrote:
once you've read in your data using NOUMEA2_ID and DUMBEA2_ as the ID
variables, changing the values in the data frame won''t change the ID
attached to each feature.

 You need to use the "spChFIDs-methods" to create new spatial polygons
data frames with unique IDs between them.

 Here, scot1 is the first 10 features from scot_BNG as read in help(rgdal)

 > scot2=scot1
 > scot12=spRbind(scot1,scot2)
 Error in spRbind(as(obj, "SpatialPolygons"), as(x, "SpatialPolygons")) :
  non-unique polygon IDs

 - that fails because the IDs are the same. So we change scot2 to be
"A" to "J" (which isnt what the IDs are currently...)

 > scot2=spChFIDs(scot2,letters[1:10])
 > scot12=spRbind(scot1,scot2)

and that works.

Barry