On Thu, Jan 27, 2011 at 2:29 AM, Oliver Tonnhofer <[email protected]> wrote:
> my observations are that wkt.loads is faster than creating lines or polygons
> from list or tuples of coordinates. It's a bit unfortunate, but the only API
> to set a coordinate sequence are the CoordSeq_Set_X/Y functions and calling
> these thousands of times with ctypes is expensive. I already thought about
> implementing the geos_linearring_from_py function in cython or pyrex as an
> optional speedup, but I don't know if and how this works in combination with
> ctypes.
>
> Regards,
> Oliver
I ended up spending a lot of time doing string joins. However you got
me going on the right track! I ended up getting about a 10%
improvement with this code that uses WKB instead:
header = '\x01\x03\x00\x00\x00\x01\x00\x00\x00\x04\x00\x00\x00%s'
poly = wkb.loads(header % (struct.pack('8d', point_data),))
Since this is at least forward-compatible, I think I'll stick with it
and call the modest speed improvement good enough.
-Kyle
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community