[R-sig-Geo] merging polygons by indices
Roger Bivand
Roger.Bivand at nhh.no
Wed Aug 17 00:27:32 CEST 2011
On Tue, 16 Aug 2011, majesty wrote:
> still I am not quiet sure how to achieve this by manipulation of ID. Could
> you give an example, say I have 5 polygons in my shapefile shape.shp but
> would like to have 4 polygons, where shape[2] is merged with shape[3]. I am
> somewhat clueless because ID has to be of equal in length to polygons slot
> (in my case 5)
So maybe try:
shape1 <- unionSpatialPolygons(shape, IDs=as.character(shape$output_area))
which will copy across the unchanged entities, and join the ones with
multiple output_area IDs. Note that the only way to retrieve the IDs will
be row.names(shape1), as the function doesn't aggregate other data in
shape.
Hope this helps,
Roger
>
> Thanks,
>
> Juta Kawalerowicz
>
>
> MPhil Candidate in Sociology
> Oxford University
>
>
> --
> View this message in context: http://r-sig-geo.2731867.n2.nabble.com/merging-polygons-by-indices-tp6691746p6692261.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
Department of Economics, NHH Norwegian School of Economics,
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