Discussion:
[Community] Shapely and affine transformations
Matthias Blaicher
2013-12-03 14:07:16 UTC
Permalink
Hello,

I'm currently using Shapely for optical computer chip design and the
first prototypes work great. The only thing I am not satisfied with is
the speed. I first assumed this to be caused by all the geometry
operations I do, but after profiling it looks like most of the time is
spent doing simple affine transformations, especially in affine_transform.

Is this just my own impression or is it a known area which needs
performance improvements?

Best,
Matthias
Mike Toews
2013-12-05 20:00:06 UTC
Permalink
Hi Matthias,

The bottleneck is due to reading coordinates from a geometry, doing
the transform on each vertex/point, then re-creating a new geometry.
This is done in Python.

A faster approach would be to do an in-place geometry edit, where the
coordinate sequences are modified without requiring the geometry to be
re-created. One way to do this is to implement this with GEOS, but
that development won't happen quickly or easily (requires lots of C++
and C-API patching).

There might be a way to use the existing GEOSGeom_getCoordSeq then
GEOSCoordSeq_setX/Y/Z to modify coordinates of geometries in-place. I
have no idea if this could work, or if it would be faster.

-Mike
Post by Matthias Blaicher
Hello,
I'm currently using Shapely for optical computer chip design and the
first prototypes work great. The only thing I am not satisfied with is
the speed. I first assumed this to be caused by all the geometry
operations I do, but after profiling it looks like most of the time is
spent doing simple affine transformations, especially in affine_transform.
Is this just my own impression or is it a known area which needs
performance improvements?
Best,
Matthias
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
Sean Gillies
2013-12-08 06:51:37 UTC
Permalink
Hi Mike, Matthias,

We could rewrite the affinity module as a C extension using Cython like in
shapely/speedups/_speedups.pyx. It would certainly be faster.

Can one of you create an issue at
https://github.com/Toblerity/Shapely/issues if you're seriously interested?
Post by Mike Toews
Hi Matthias,
The bottleneck is due to reading coordinates from a geometry, doing
the transform on each vertex/point, then re-creating a new geometry.
This is done in Python.
A faster approach would be to do an in-place geometry edit, where the
coordinate sequences are modified without requiring the geometry to be
re-created. One way to do this is to implement this with GEOS, but
that development won't happen quickly or easily (requires lots of C++
and C-API patching).
There might be a way to use the existing GEOSGeom_getCoordSeq then
GEOSCoordSeq_setX/Y/Z to modify coordinates of geometries in-place. I
have no idea if this could work, or if it would be faster.
-Mike
Post by Matthias Blaicher
Hello,
I'm currently using Shapely for optical computer chip design and the
first prototypes work great. The only thing I am not satisfied with is
the speed. I first assumed this to be caused by all the geometry
operations I do, but after profiling it looks like most of the time is
spent doing simple affine transformations, especially in
affine_transform.
Post by Matthias Blaicher
Is this just my own impression or is it a known area which needs
performance improvements?
Best,
Matthias
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
--
Sean Gillies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gispython.org/pipermail/community/attachments/20131207/fe70a9ae/attachment.htm>
Loading...