[R-sig-Geo] gUnaryUnion does not work on my SpatialPolygonsDataFrame?

Edzer Pebesma edzer.pebesma at uni-muenster.de
Wed Jul 8 21:49:55 CEST 2015

Hi Ulrike, does

a = aggregate(BW_EU, list(BW_EU$BRFW), dissolve = TRUE)

plot(BW_EU, border = 'grey')
plot(a, add = TRUE)

give what you want? I believe that none of the rgeos functions (can) do
anything with polygon attributes, such as BRFW.

Best regards,

On 07/08/2015 08:57 PM, Ulrike Grömping wrote:
> Dear R-sig-Geos,
> I am quite new to geographical data in R and also to shape files etc.,
> and I have encountered the following difficulty: After reading a
> publicly available shape file on recent EU elections in Berlin (link
> https://www.statistik-berlin-brandenburg.de/opendata/RBS_OD_STI_EU1405.zip)
> with the ReadShapePoly command, it contains the Berlin EU election
> "Stimmbezirke" (variable STI), as expected, and they can be plotted.
> When using the gUnaryUnion or the gUnionCascaded function from rgeos for
> uniting several "Stimmbezirke" into the larger postal voting units
> (variable BRFW), the result is one single polygon instead of the
> expected 529 such units; plotting it shows a shape that does not explain
> itself to me.
> BW_EU <- readShapePoly("RBS_OD_STI_EU1405.shp")  ## shape directory is
> working directory
> plot(BW_EU)   ## plots the expected "Stimmbezirke"
> BW_EU_BRFW <- gUnionCascaded(BW_EU, "BRFW")  ## gUnaryUnion does not
> make a difference
> plot(BW_EU_BRFW)   ## plots only a single outline
> I then tried to use gUnaryUnion with the variable STI (which I expected
> to return the unchanged polygons), which apparently returned exactly the
> same outline as the one obtained with BRFW. Presumable, I am overlooking
> something basic here, but I fail to see what. Can someone help?
> Thanks in advance!
> Best, Ulrike

Edzer Pebesma
Institute for Geoinformatics (ifgi),  University of Münster,
Heisenbergstraße 2, 48149 Münster, Germany; +49 251 83 33081
Journal of Statistical Software:   http://www.jstatsoft.org/
Computers & Geosciences:   http://elsevier.com/locate/cageo/
Spatial Statistics Society http://www.spatialstatistics.info

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: OpenPGP digital signature
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20150708/a62492b9/attachment.bin>

More information about the R-sig-Geo mailing list