1

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

enter image description here

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?

1
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 SCA provinces

Based on this answer:

#Merge 3 sub-regions into 1
sca <- as(sca, "SpatialPolygons")
sca <- unionSpatialPolygons(sca, rep(1, 3))

Based on this answer:

#Convert SpatialPolygons object into owin object
sca <- as.owin(sca)
plot(sca)

enter image description here I don't know how to preserve a graphic representation of the internal borders, but this answers my main question.

EDIT: Converting to owin before merging preserves borders

#Pick up code immediately after subsetting SCA provinces

#Convert into owin
sca <- as(sca, "SpatialPolygons")
sca <- as.owin(sca)

#Merge 3 sub-regions into 1
sca <- union.owin(sca)
plot(sca)

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.