I wish to combine multiple shapefiles for different regions and assign them names in R/sf. I'm not sure if my procedure is orthodox. That may also be the reason for the incorrect boundary box which results.
The raw data is a set of three shapefiles downloaded from this site (in Korean). I attach the files, as they are not accessible outside Korea. The files are for the Seoul, Incheon and Gyeonggi-do regions. I want to combine them into the Seoul Capital Area. At the same time, I wish to name them in Roman script. Here's the code:
library(sf) #Read, combine and name shapefiles sca_nsdi <- rbind(data.frame(st_read("LARD_ADM_SECT_SGG_11.shp"), Name="Seoul", stringsAsFactors=F), data.frame(st_read("LARD_ADM_SECT_SGG_28.shp"), Name="Incheon", stringsAsFactors=F), data.frame(st_read("LARD_ADM_SECT_SGG_41.shp"), Name="Gyeonggi-do", stringsAsFactors=F)) #Convert back to sf dataframe (according to https://github.com/r-spatial/sf/issues/193#issuecomment-276354417) st_geometry(sca_nsdi) <- sca_nsdi$geometry
I'm not sure if this the right way to go. The boundary box of the merged set is the same as the boundary box of Seoul, which is smaller than surrounding Gyeonggi-do. I don't know how to correct that, but I'm also wondering if my procedure produces other undesirable side-effects which I haven't detected yet.
st_bbox(sca_nsdi)==st_bbox(sca_nsdi[sca_nsdi$Name=="Seoul",]) #returns all TRUE plot(sca_nsdi$geometry) #returns truncated map plot(sca_nsdi$geometry[sca_nsdi$Name=="Seoul",], add=T, lwd=2) #superimprints Seoul in bolder lines