Thanks so much On Thu, Feb 18, 2016 at 3:23 PM, chris english < englishchristoph...@gmail.com> wrote:
> John, > > As Loic suggests, rgeos::gIntersection will get you there. Look closely at > his naming of objects and your example code using spTransform. With his > approach, each object has its own name; whereas your approach overwrites > Rain_poly_merge the second and third time and the final object (third) is > the 2008 maize yield. So read your shapefiles into differently named > objects and use Loic's approach. > > Chris > > On Thu, Feb 18, 2016 at 1:58 PM, A. Marcia BARBOSA <barb...@uevora.pt> > wrote: > > > Check out also function joinPolys in the PBSmapping package > > (http://www.inside-r.org/packages/cran/pbsmapping/docs/joinPolys) > > > > > > - - - > > A. Márcia BARBOSA, post-doctoral fellow > > CIBIO/InBIO - University of Évora (Portugal) > > http://modtools.wordpress.com/barbosa > > > > > > > > 2016-02-18 10:04 GMT+00:00 Loïc Dutrieux <loic.dutri...@wur.nl>: > > > > > 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@r-project.org > > >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo > > >> > > >> > > > _______________________________________________ > > > R-sig-Geo mailing list > > > R-sig-Geo@r-project.org > > > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > > > > > > > [[alternative HTML version deleted]] > > > > _______________________________________________ > > R-sig-Geo mailing list > > R-sig-Geo@r-project.org > > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > > > > [[alternative HTML version deleted]] > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > -- John Wasige "There are no REGRATES in LIFE, just lessons (Jennifer Aniston)” [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo