I wish to import shapefiles of the Seoul Capital Area to use as a window in spatstat
. The SCA is the combination of the Seoul, Incheon, and Gyeonggi-do level-1 administrative areas of South Korea.
I download shapefiles for South Korea from GADM (unless there is a better source for Korean provinces). The zip file contains KOR_adm1.shp
for level-1 administrative areas of South Korea.
library(rgeos) #required by maptools
library(maptools)
library(spatstat)
sca <- readShapeSpatial("KOR_adm1.shp") #upload Korean provinces
sca <- sca[sca@data$NAME_1 %in% c("Seoul", "Incheon", "Gyeonggi-do"),] #subset required 3 areas
plot(sca) #plot reveals an anomaly in the bottom right corner
sca <- as.ppp(sca) #convert 3 areas to spatstat ppp format returns an error
Error in as.ppp.default(sca) : Can't interpret X as a point pattern
seoul <- as.ppp(sca[sca@data$NAME_1=="Seoul",]) #convert 1 area to spatstat ppp format returns the same error
Error in as.ppp.default(sca[sca@data$NAME_1 == "Seoul", ]) : Can't interpret X as a point pattern
My question is how to convert Seoul Capital Area shapefiles into a single window for spatstat
and secondarily whether it's possible to preserve the boundaries for the 3 sub-areas within that window. This vignette advises (p2) to "[multiply] the longitude coordinates by the cosine of the latitude of the centre of the region." Is this also recommended in this case?