Re: [R] calculate area between intersecting polygons

2010-10-27 Thread jonas garcia
Many thanks for your help! Thanks to you guys I manage to solve my problem in an efficient way All the best J On Tue, Oct 26, 2010 at 11:04 PM, Remko Duursma remkoduur...@gmail.comwrote: I don't know why I forgot that you can do this as well : area.poly(intersect(p1,p2)) ... a bit more

Re: [R] calculate area between intersecting polygons

2010-10-26 Thread jonas garcia
Thanks for your reply, My main issue is that I don't have any equations to generate the data, just a bunch of points, each corresponding to a polygon. I was looking in package sp and there is a function to calculate areas ( areapl()), but not for intersecting polygons. Is there any other package

Re: [R] calculate area between intersecting polygons

2010-10-26 Thread Hans W Borchers
jonas garcia garcia.jonas80 at googlemail.com writes: Thanks for your reply, My main issue is that I don't have any equations to generate the data, just a bunch of points, each corresponding to a polygon. I was looking in package sp and there is a function to calculate areas (

Re: [R] calculate area between intersecting polygons

2010-10-26 Thread Remko Duursma
Here is a different solution: library(gpclib) p1 - as(poly1, gpc.poly) p2 - as(poly2, gpc.poly) area.poly(p2) + area.poly(p1) - area.poly(union(p1,p2)) I.e., take areas of both polygons and subtract the union (check plot(union(p1,p2)) ) to get the area of the intersection. greetings, Remko

Re: [R] calculate area between intersecting polygons

2010-10-26 Thread Yves Reecht
Dear Jonas, I already had to deal with such an issue. Your can use the joinPolys function from the package PBSmapping, with INT as operation. The maptools package has functions SpatialPolygons2PolySet and PolySet2SpatialPolygons to switch between formats suitable for sp or PBSmapping. Hope this

Re: [R] calculate area between intersecting polygons

2010-10-26 Thread Hans W Borchers
Remko Duursma remkoduursma at gmail.com writes: Here is a different solution: library(gpclib) p1 - as(poly1, gpc.poly) p2 - as(poly2, gpc.poly) area.poly(p2) + area.poly(p1) - area.poly(union(p1,p2)) I.e., take areas of both polygons and subtract the union (check plot(union(p1,p2))

Re: [R] calculate area between intersecting polygons

2010-10-26 Thread Remko Duursma
I don't know why I forgot that you can do this as well : area.poly(intersect(p1,p2)) ... a bit more straightforward. greetings, Remko -- View this message in context: http://r.789695.n4.nabble.com/calculate-area-between-intersecting-polygons-tp3012980p3014581.html Sent from the R help

[R] calculate area between intersecting polygons

2010-10-25 Thread jonas garcia
Dear list: I am trying to calculate the intersection area between two irregular polygons (see example data below). set.seed(1234) theta - seq(0, 2 * pi, length=(100)) poly1- cbind(c(0 + 1 * cos(theta) + rnorm(100, sd=0.1)), c(0 + 2 * sin(theta))) poly2- cbind(c(0 + 2 * cos(theta) ),

Re: [R] calculate area between intersecting polygons

2010-10-25 Thread Remko Duursma
Dear Jonas, if you can write the difference in y-values between your polygons as a function, you can use integrate() to get the area between the polygons. It sounds like perhaps your x-values will not match between the polygons because they come from different sources, so you probably have to