Hi Markus,

I have had success with a somewhat smaller point-in-polygon problem
using a relational database (PostgreSQL) with suitable indexes to
determine containment.  The database serves as a large lookup table for
this purpose, using RODBC.  I use R to build a series of SQL INSERT
statements to load an appropriate database table, and the built-in
geometric operator for containment to do the lookup.  MySQL also has
geometric operations.

I cannot speak to performance with overlapping polygons as mine are
disjoint, but I bet they are easier to manage in the relational database
than in R tables.

Best of luck,

 - Jan,
   Akamai Technologies, inc

> Date: Thu, 13 Dec 2007 10:23:35 -0500 (EST)
> From: Markus Loecher <loecher@eden.rutgers.edu>
> Subject: [R-sig-Geo] point.in.polygon() on massive datasets
> To: r-sig-geo@stat.math.ethz.ch
> Message-ID: <8517866.3621197559414832.JavaMail.tomcat@aveo>
> Content-Type: text/plain; charset=us-ascii
> 
Dear all,
> I have a dataset of about 50 million lat/lon coordinates each of which
falls into one of 550 polygons.
> I need to assign their memberships and have used point.in.polygon()
for that purpose.
> However, the simple way of looping over the 50 million points clearly
takes a looong time; 1 million points took about 3-4 days on a fast
Linux server with lots of memory.
> Am I overlooking obvious ways of making this massive computation more
efficient ? Would R trees help ?
> Should I try to compile the C code for point.in.polygon() (available
from gstat) and run it outside R as a standalone executable ?
> I am already using apply() to mitigate the inefficiency of the for
loop in R.
> 
Any help would be greatly appreciated,
> 

[snip]



	[[alternative HTML version deleted]]


