Combining polygons from a SpatialPolygonsDataFrame object
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
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>