New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert from a list of Points to a Polygon #21
Comments
Here's thing: polygon rings (instances of LinearRing) aren't defined by Points, they are defined by sequences of coordinate tuples. Points and coordinates are different things to Shapely. You need to pass the coordinates of the points to the Polygon constructor. Like this:
|
As I keep googling for this every now and then, here is how I prefer to do it (I find it more readable like this):
timeit says things might be getting cached but @sgillies's approach seems consistently 2/3 faster (~65µs mine vs ~45µs his) so if you need super ultra hardcore performance for gazillions of points or polys, consider that. |
Ever so slightly faster again:
|
Rewrite constructive tests + fixes
Hi all,
I didn't find a mailing list of a forum, so I'm going to ask here. Is there a "canonical" form to convert from a list of Points to a Polygon? For example,
This code doesn't work. I had to use convex_hull:
What is not exaclty what I'm looking for.
Thanks for the patience and the good work!
The text was updated successfully, but these errors were encountered: