Combine neighboring regions in R (cumulative spatial data)?

I think I needed to rephrase my terribly worded previous question (deleted it). Here is another try. I want to join the neighboring regions so that their common border disappears, and only their outer line can be seen.

Here's a reproducible example:

require(shapefiles)
require(sp)

xx <- readShapeSpatial(system.file("shapes/sids.shp", package="maptools")[1],
                   IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))

# show all the subregions
plot(xx)

enter image description here

Now we consider only the areas of regions 3 and 5

plot(xx[c(3,5),])

How can I just fill in these regions. In practice, what I want to do is that the map of the entire continent shows all countries and creates a map showing North America and South America.

For me, this seems like a fairly general task, but I still can not find the desired function. I just missed a function or can I just manually do it?

enter image description here

+5
source share
1

rgeos Spatial*, .

:

library(rgeos)
regionOfInterest <- gUnion(xx[3,], xx[5,])

:

regionOfInterest <- gUnionCascaded(xx[c(3,5), ])

plot(regionOfInterest):

enter image description here

+9

All Articles