Skip to content
Prev 7390 / 29559 Next

Alternate methods: Polygon Algebra / Polygon Overlay with R Spatial objects..

On Fri, 15 Jan 2010, rick reeves wrote:

            
For union, aka dissolve, see unionSpatialPolygons() in maptools. Perhaps 
better, don't look yet. The underlying problem is the license of the 
gpclib package, which should be avoided. The reason for attention to 
package licenses is that CRAN is getting very large, and taking 
responsibility for distributing non-free software through package 
dependencies needs to be automated. So GPL and other free packages should 
not depend on or suggest non-free packages, because users (including 
commercial users) may not be aware that they are using packages with 
non-free licences. Some of these users already block the installation of 
free packages with "upstream" non-free dependencies, and more will do so 
in the future.

One solution is the R-Forge rgeos package, which I'm working on.

https://r-forge.r-project.org/projects/rgeos/

Before long, again thanks to Uwe Ligges and others, we should have a 
working production line for Windows binary packages with GEOS 3.1.1 
included. Linux distributions have binaries or can install from source; 
OSX has a Kyngchaos framework to handle the external dependency on GEOS.

rgeos has unionSpatialPolygonsGEOS(), which, when rgeos reaches CRAN, will 
be used by maptools in unionSpatialPolygons() if rgeos is available.

GEOS has the necessary functions to do what you would like, but someone 
has to write the R and C code and add it to rgeos. The current 
SpatialLinesIntersections() function returns a SpatialPointsDataFrame 
object with the IDs if the intersecting lines, but more is needed for 
SpatialPolygons intersection. The handling of the data frame variables is 
far from obvious too - just copying across count or rate variables isn't 
appropriate. Most likely the handling of the data slots would have to be 
done by hand for the new SpatialPolygons objects based on the intersecting 
ID values.

R-Forge has the possibility for new developers to join projects ...

Hope this helps,

Roger