Re: [R] Faster union of polygons?

2010-06-04 Thread Remko Duursma
Martin, thanks a lot! This speeds things up so much Do you mind if I bundle your punion function in a package I am developing (but of course I will name you the author of the function)? greetings, Remko On Fri, Jun 4, 2010 at 12:17 PM, Martin Morgan mtmor...@fhcrc.org wrote: On

Re: [R] Faster union of polygons?

2010-06-03 Thread nikhil kaza
Reduce might work. Not sure about the speed advantages though. It does simplify code. Unionall - function(x) Reduce('union', x) leaveout - Unionall(leaves) On Tue, Jun 1, 2010 at 9:53 PM, Remko Duursma remkoduur...@gmail.comwrote: Dear R-helpers, thanks for yesterday's speeding-up tip.

Re: [R] Faster union of polygons?

2010-06-03 Thread Remko Duursma
Thanks for the tip - this cleans up the code a lot! Unfortunately, there is no gain in speed. remko On Thu, Jun 3, 2010 at 10:46 PM, nikhil kaza nikhil.l...@gmail.com wrote: Reduce might work. Not sure about the speed advantages though. It does simplify code.  Unionall - function(x)

Re: [R] Faster union of polygons?

2010-06-03 Thread Martin Morgan
On 06/03/2010 04:54 PM, Remko Duursma wrote: Thanks for the tip - this cleans up the code a lot! Unfortunately, there is no gain in speed. Playing a little bit dirty, punion - function(...) { n - nargs() if (0L == n) new(gpc.poly) else if (1L == n is(..1, gpc.poly)) ..1

Re: [R] Faster union of polygons?

2010-06-02 Thread Remko Duursma
Baptiste, thanks for the tip but this would give me an approximate union, and I really need a (nearly) exact one. I am also not sure how to set the alpha parameter in a non-arbitrary way. Remko - Remko Duursma Research Lecturer Centre for

[R] Faster union of polygons?

2010-06-01 Thread Remko Duursma
Dear R-helpers, thanks for yesterday's speeding-up tip. Here is my next query: I have lots of polygons (not necessarily convex ones, and they never have holes) given by x,y coordinates. I want to get the polygon that is the union of these polygons. This is my current method, but I am hoping

Re: [R] Faster union of polygons?

2010-06-01 Thread baptiste auguie
Hi, I think you could use a concave hull from the alphahull package, http://yihui.name/en/2010/04/alphahull-an-r-package-for-alpha-convex-hull/ It may be difficult to find the right parameters if the polygons differ widely in edge lengths, though. HTH, baptiste On 2 June 2010 03:53, Remko