[Community] confusion with convex hull w/ shapely
Sean Gillies
sean.gillies at gmail.com
Fri Mar 26 21:55:49 EET 2010
Kurt,
A non-closed line segment has a boundary equal to a set of two points.
Linear rings (such as a polygon's boundary) don't have boundaries.
That's part of the definition of being a closed curve. You're looking
at a GEOS bug in which polygon boundaries are returned as linestrings
instead of rings. IIRC, Charlie Savage and I closed that before the
3.0 release. Are you using a very old GEOS?
On Mar 26, 2010, at 7:48 PM, Kurt Schwehr wrote:
> Since I'm parsing the original data, is seams a shame to have to
> leave python to do a convex hull.
>
> Either way, it looks to me like there is a bug with boundary:
>
> In [10]: line.wkt
> Out[10]: 'LINESTRING (-0.5000000000000000 0.5000000000000000,
> -1.5000000000000000 1.2000000000000000, -1.0000000000000000
> 1.0000000000000000, -0.5000000000000000 0.5000000000000000)'
>
> In [13]: line.boundary.is_empty
> Out[13]: True
>
> From the manual, it looks like boundary of a line shouldn't be empty.
>
> -kurt
>
>
> On Mar 26, 2010, at 2:05 PM, Howard Butler wrote:
>
>>
>> On Mar 26, 2010, at 1:01 PM, Kurt Schwehr wrote:
>>
>>> I am a little confused with the convex hull functionality. Can
>>> someone set me straight?
>>>
>>>
>>> In [29]: type(ch)
>>> Out[29]: <class 'shapely.geometry.polygon.Polygon'>
>>>
>>> In [30]: ch.wkt
>>> Out[30]: 'POLYGON ((-0.5000000000000000 0.5000000000000000,
>>> -1.5000000000000000 1.2000000000000000, -1.0000000000000000
>>> 1.0000000000000000, -0.5000000000000000 0.5000000000000000))'
>>>
>>> In [31]: ch.boundary
>>> Out[31]: <shapely.geometry.linestring.LineString object at
>>> 0x13c0a10>
>>>
>>> In [32]: ch.boundary.wkt
>>> Out[32]: 'LINESTRING (-0.5000000000000000 0.5000000000000000,
>>> -1.5000000000000000 1.2000000000000000, -1.0000000000000000
>>> 1.0000000000000000, -0.5000000000000000 0.5000000000000000)'
>>>
>>> In [33]: ch.boundary.boundary
>>> Out[33]: <shapely.geometry.multipoint.MultiPoint object at
>>> 0x13c0eb0>
>>>
>>> In [34]: ch.boundary.boundary.wkt
>>> Out[34]: 'MULTIPOINT EMPTY'
>>>
>>> Here is where I thought I would have a multipoint with my points.
>>> I thought it would take me one more level of bounary call to get
>>> to empty. Basically, I want to build a convex hull of 10M
>>> points... I was thinking that it would be way more efficient to
>>> add each point and compute a new convex hull. What is the best
>>> way to attack something like this?
>>
>> You want http://www.cs.unc.edu/~isenburg/lastools/download/lasboundary_README.txt
>> It can give you the convex or *concave* hull(s) of varying
>> tightnesses. This is not a job for GEOS.
>>
>> Howard
>
--
Sean
More information about the Community
mailing list