[R-sig-Geo] extracting the non-overlapping part of a polygon?

Malcolm Fairbrother m.fairbrother at bristol.ac.uk
Thu Jan 6 12:15:59 CET 2011


Dear all,

Is there a straightforward way of changing the shape of a polygon "A", by superimposing another polygon "B", and keeping only that part of "A" which is not overlapped by "B"?

In brief, and as a reproducible example, I'm trying to get a polygon for Greek Cyprus. It's easy to get a polygon for the whole island, and I've found a polygon of just the Turkish part of Cyprus. But I can't find a polygon for the Greek part alone, and it seems like there might be a way to create one by carving out the Turkish part from the whole island:

library(cshapes)
world <- cshp(date=as.Date("2008-6-30"))
cy <- world[world$CNTRY_NAME=="Cyprus",]

library(maptools)
download.file(url="http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/cultural/50m-admin-0-breakaway-disputed-areas.zip", dest="50m-admin-0-breakaway-disputed-areas.zip")
unzip("50m-admin-0-breakaway-disputed-areas.zip")
brk <- readShapeSpatial("50m-admin-0-breakaway-disputed-areas.shp", proj4string=CRS("+proj=longlat +ellps=WGS84"))
tuc <- brk[brk$Name=="Turkish Republic of Northern Cyprus",]

plot(cy)
plot(tuc, add=T)

Any assistance/suggestions would be much appreciated. Apologies if I've overlooked anything obvious.

- Malcolm



More information about the R-sig-Geo mailing list