[R-sig-Geo] UnionSpatialPolygons in the German DEU_adm3.RData file

Roger Bivand Roger.Bivand at nhh.no
Mon Jan 31 09:19:45 CET 2011


On Sun, 30 Jan 2011, DPajak wrote:

>
> Hello,
>
> actually I started to learn how to produce a choropleth map today. So
> hopefully somebody can help me?
>
> I want to use the GADM data file for Germany (DEU_adm3.RData) along with
> some data from my dissertation in business studies. So far so good. Since
> there are some good examples out there it was easy to merge those two files.
>
> The problem I have is due to some local government reorganizations (e.g. the
> Kreisgebietsreform 2008 in Saxony).
>
> So I have to merge some district in the DEU_adm3.RData file. 
>
> I learnt today, that the "UnionSpatialPolygons" of the GPC library can do
> that. 
>
> So I tried to figured out, how to use this function. Here is what I have so
> far:
>
> ---
> library(sp)
> library(maptools)
> library(gpclib) #
> http://en.wikipedia.org/wiki/GPC_General_Polygon_Clipper_Library
> gpclibPermit() 
> Germany <-load("./Dropbox/Projekte/Spatial Map/DEU_adm3.RData")
>
> write.csv(gadm, "gadm-data.csv")
>
> # ID_3 for the three former districts Döbeln (23204), Freiberg (23185) &
> Mittweida (23187)
>
> Merge_Mittelsachsen <- gadm[gadm$ID_3 %in% c("23185","23187","23204"),]
> ID <- rep("Mittelsachsen", length(slot(Merge_Mittelsachsen, "polygons")))
> Mittelsachsen <- unionSpatialPolygons(Merge_Mittelsachsen, ID)
> plot(Mittelsachsen)
> ---
>
> This works perfectly to plot the new district of Mittelsachsen
> (Middle-Saxony).

IDs <- gadm$ID_3
IDs[IDs %in% c("23185","23187","23204")] <- "Merge_Mittelsachsen"
gadm_new <- unionSpatialPolygons(gadm, IDs)

The unaltered entities are passed through unchanged, the non-unique IDs 
are merged.

Roger

>
> But how can I combine this new merged district with the rest of the German
> map? Or in others words, how can I overwrite the former three separated
> districts with my new "Mittelsachsen" polygon.
>
> Thank you very much for any hints you can give me.
>
> Danny Pajak
>
>
>
>
> -- 
> View this message in context: http://r-sig-geo.2731867.n2.nabble.com/UnionSpatialPolygons-in-the-German-DEU-adm3-RData-file-tp5975724p5975724.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no


More information about the R-sig-Geo mailing list