[R-sig-Geo] Intersect shapefiles

Loïc Dutrieux loic.dutrieux at wur.nl
Thu Feb 18 11:04:54 CET 2016


Hi,

Have you tried gIntersection from the rgeos package.

Given 3 SpatialPolygon* objects you can probably do something like:

sp12 <- gIntersection(sp1, sp2)
sp123 <- gIntersection(sp12, sp3)

Cheers,
Loïc

On 02/18/2016 10:25 AM, John Wasige wrote:
> ​Dear all,
>
> I have three shapefiles that I want to intersect. Any body with an idea on
> how to do the intersection? Shapefiles below;
> library(rgdal)
> library(rgeos)
> library(maptools)
> library(sp)
> ###shape1
> Rain_poly_merge <- readOGR(dsn="G:/EPIC_CUP/Rain_poly_merge.shp",
> layer="Rain_poly_merge")
> Rain_poly_merge <- spTransform(Rain_poly_merge, CRS("+init=epsg:4326"))
>
> ###shape2
> Rain_poly_merge <- readOGR(dsn="G:/EPIC_CUP/yield_maize_average2002.shp",
> layer="Rain_poly_merge")
> Rain_poly_merge <- spTransform(Rain_poly_merge, CRS("+init=epsg:4326"))
>
> ###shape3
> Rain_poly_merge <- readOGR(dsn="G:/EPIC_CUP/yield_maize_average2008.shp",
> layer="Rain_poly_merge")
> Rain_poly_merge <- spTransform(Rain_poly_merge, CRS("+init=epsg:4326"))
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



More information about the R-sig-Geo mailing list