[R-sig-Geo] Combining polygons from a SpatialPolygonsDataFrame object

O'Hanlon, Simon J simon.ohanlon at imperial.ac.uk
Thu Jun 14 11:15:35 CEST 2012


Hi Jesús,
Check out maptools::unionSpatialPolygons. This function takes a spatial polygons object and aggregates polygons according to a vector ID which tell the function what input polygons belong to which output polygons, in your case the province IDs.

Note you may need to set gpclibPermit() to allow use of the gpclib package if rgeos is not available on your system.

HTH,

Simon


--------------------------------
Simon O'Hanlon, BSc MSc
Department of Infectious Disease Epidemiology
Imperial College London
St. Mary's Hospital
London
W2 1PG
________________________________
From: r-sig-geo-bounces at r-project.org [r-sig-geo-bounces at r-project.org] on behalf of Alonso Nanclares, Jesús Alberto [jaalonson at indra.es]
Sent: 14 June 2012 08:45
To: r-sig-geo at r-project.org
Subject: [R-sig-Geo] Combining polygons from a SpatialPolygonsDataFrame object

Dear list,

I have a Shapefile representing the censal sections of Spain, and my interest is creating a KML file with only 52 polygons representing the different provinces of Spain. I shall use readOGR, and my problem comes when I have a SpatialPolygonsDataFrame object in R and I want to merge in only one polygon all the censal sections of every province. I have an attribute with the province ID defined in the same object, so it would only be aggregating the censal sections with the same province ID, but still I don’t know how to do it.

I shall be grateful for any help. My kind regards,

Jesús Alberto Alonso Nanclares
Consultor Junior
Centro de Competencias Business Analytics

Avda de Bruselas, 35
28108 Alcobendas (Madrid)
España

T +34 914 805 863
jaalonson at indra.es
www.indracompany.com<http://www.indracompany.com>

[indra]


________________________________
Este correo electrónico y, en su caso, cualquier fichero anexo al mismo, contiene información de carácter confidencial exclusivamente dirigida a su destinatario o destinatarios. Si no es vd. el destinatario indicado, queda notificado que la lectura, utilización, divulgación y/o copia sin autorización está prohibida en virtud de la legislación vigente. En el caso de haber recibido este correo electrónico por error, se ruega notificar inmediatamente esta circunstancia mediante reenvío a la dirección electrónica del remitente.
Evite imprimir este mensaje si no es estrictamente necesario.

This email and any file attached to it (when applicable) contain(s) confidential information that is exclusively addressed to its recipient(s). If you are not the indicated recipient, you are informed that reading, using, disseminating and/or copying it without authorisation is forbidden in accordance with the legislation in effect. If you have received this email by mistake, please immediately notify the sender of the situation by resending it to their email address.
Avoid printing this message if it is not absolutely necessary.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20120614/5da25066/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 1907 bytes
Desc: image001.jpg
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20120614/5da25066/attachment.jpg>


More information about the R-sig-Geo mailing list