[R] sp package - How to join two or more polygons from a SpatialPolygonsDataFrames

Mark Heckmann mark.heckmann at gmx.de
Thu Jan 21 17:21:33 CET 2010


I have a SpatialPolygonsDataFrame object (sp package).
It contains 40 polygons.
Now I want to join some of the polygones.
I cannot figure out how to do that? Any ideas?

The code below produces a map of Germany and I need to join some  
counties.

library(sp)
library(RColorBrewer)

# get spatial data for Germany on county level
con <- url("http://gadm.org/data/rda/DEU_adm3.RData")
print(load(con))
close(con)

# plot Germany with random colors
col = rainbow(length(levels(gadm$NAME_3)))
spplot(gadm, "NAME_3", col.regions=col, main="German Regions",
        colorkey = FALSE, lwd=.4, col="white")


–––––––––––––––––––––––––––––––––––––––
Mark Heckmann
Dipl. Wirt.-Ing. cand. Psych.
Vorstraße 93 B01
28359 Bremen
Blog: www.markheckmann.de
R-Blog: http://ryouready.wordpress.com



More information about the R-help mailing list