[R-sig-Geo] SpatialPolygonsDataFrame converted to SpatialPolygons after union

Oscar Breugelmans Oscar.Breugelmans at rivm.nl
Fri May 9 16:02:39 CEST 2008

Dear list,

I have a postal code map of the Netherlands. I use the area code PC4NR as
the identifier for each area. After making a subset of the areas, I use
unionSpatialPolygons to combine the polygons (areas) that have a different
ID, but the same PC4NR. When using unionSpatialPolygons, my
SpatialPolygonsDataFrame is converted into a SpatialPolygons object,
thereby losing all the auxilliary information contained in the dataframe. I
want to return to shapefile format after this, but writePolyShape doesn't
work anymore after the union.
Is there any way to perform the union while retaining the
SpatialPolygonsDataFrame class? The R code is below.
Any help is appreciated.

Oscar Breugelmans


pc4.00.subset<-pc4.00[!pc4.00$PC4NR %in%


pc4.00.union<-unionSpatialPolygons(as(pc4.00.subset, "SpatialPolygons"),


DISCLAIMER:  http://www.rivm.nl/disclaimer.htm\ ...{{dropped:2}}

More information about the R-sig-Geo mailing list