2

I want to combine the SpatialPolygonsDataFrame of two neighbour countries like Pakistan and India. My MWE is below:

library(raster)
Pakistan.adm1.spdf <- 
  getData(
    "GADM"
    , country = "Pakistan"
    , level = 1
  )

India.adm1.spdf <- 
  getData(
    "GADM"
    , country = "India"
    , level = 1
  )

How can I combine these two shapefiles?

halfer
  • 19,824
  • 17
  • 99
  • 186
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
  • Note aside: they are not shapefiles but "SpatialPolygonsDataFrame". They are provided in .RData format. –  Jun 29 '15 at 06:21
  • Try `rbind(Pakistan.adm1.spdf, India.adm1.spdf, makeUniqueIDs = TRUE)`. [source](http://gis.stackexchange.com/questions/32732/proper-way-to-rbind-spatialpolygonsdataframes-with-identical-polygon-ids) –  Jun 29 '15 at 06:30

1 Answers1

4

From the answer to this question, use rbind and the argument makeUniqueIDs.

adm1.spdf <- rbind(Pakistan.adm1.spdf, India.adm1.spdf, makeUniqueIDs = TRUE)
plot(adm1.spdf)

enter image description here

Community
  • 1
  • 1