I'm new to working with spatial data and polygons in R.
I have two separate shape files of two polygons that I extract from Google Earth. So basically the first shape file is a location (such as a shopping mall etc.) and the second shape file is a three kilometre radius around the first location. I read both shape files into R as SpatialPolygonsDataFrames. I use the following code:
library(maptools)
library(sp)
library(spatstat)
options(digits=10)
# Read polygon a
a <- readShapeSpatial(file.choose())
class(a)
spatstat.options(checkpolygons=FALSE)
r <- slot(a,"polygons")
r <- lapply(r, function(a) { SpatialPolygons(list(a)) })
windows <- lapply(r, as.owin)
Ploy_One <- tess(tiles=windows)
# Read polygon b
b <- readShapeSpatial(file.choose())
class(b)
spatstat.options(checkpolygons=FALSE)
s <- slot(b,"polygons")
s <- lapply(s, function(b) { SpatialPolygons(list(b)) })
windows <- lapply(s, as.owin)
Poly_Two <- tess(tiles=windows)
# Read polygon b
Combined_Region <- intersect.tess(Poly_One, Poly_Two)
plot(Combined_Region)
However, I don't get a combined view of the two polygons, (view of the one polygon within the other).
If anybody have some advice on how I can code this the merge of two polygon regions into a single polygon region in R, I'd appreciate it very much!