On Thu, Jun 10, 2010 at 1:54 PM, Emmanuel Lambert
<[email protected]> wrote:
> Hello Sean,
>
> There are several problems with this method for my use :
>
> -you have to create a Point object for every point that is to be tested.
> In my case, it concerns a couple hundred million of points :)
> With this scale, using objects instead of numpy arrays for example,
> consumes gigabytes more memory.
>
> -the filter-function processes a python-list, which is also slower than
> pure processing of a numpy array completely inside the C space.
>
> So what I would like to do is the following:
>
> points = numpy.array[[10.0,12.0],[15.6,16.3]] #array with all the points
> to be tested
>
> contains_flag = polygon.contains(points)
>
> -> contains flag would then for example be : [False, True]
>
> Any plans for this? Would these semantics be compatible with the current
> way of working in shapely?
>

No, I don't think this is compatible. I'd like Shapely to stay fairly
primitive and let other packages take care of collection and iteration
semantics. For example, I'd make a contains mask like this:

  >>> from itertools import imap, izip
  >>> contains_flag = list(imap(lambda p:
polygon.contains(asPoint(p)), izip(*points)))

This doesn't accumulate a huge list of Points. It does copy your numpy
data to a GEOS structure using Python: not extremely fast. If speed is
very critical to your application, you might consider one of two
options:

1) Implement a point-in-polygon algorithm specifically for numpy (I'd
be interested in this too)
2) Write a GEOS CoordinateSequence implementation for Numpy arrays
that lets us avoid unnecessary copying (I'm also interested in this
one, and maybe also for Python's built-in arrays)

Cheers,

-- 
Sean
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community

Reply via email to