[Community] cascaded_union failure : No Shapely geometry can be created from null value
Sean Gillies
sean.gillies at gmail.com
Fri Jun 25 14:18:43 EEST 2010
As far as I know, the win32 installers since 1.2b7 have included GEOS
3.2.2. You can check like this:
>>> from shapely.geos import lgeos
>>> lgeos.geos_capi_version
(1, 7, 0)
That's the C API version. The GEOS library version can be had like
>>> lgeos._lgeos.GEOSversion()
'3.3.0-CAPI-1.7.0'
Cheers,
On Fri, Jun 25, 2010 at 1:07 PM, Emmanuel Lambert
<emmanuel.lambert at intec.ugent.be> wrote:
> Sean,
>
> Any plans to release Windows binaries with GEOS 3.2.2 ?
> Now I'm still stuck for our Windows users...
>
> thanks,
> Emmanuel
>
>
> On Fri, 2010-06-25 at 13:04 +0200, Sean Gillies wrote:
>> GEOS 3.2.2 should be fine.
>>
>> Cheers,
>>
>> On Fri, Jun 25, 2010 at 12:52 PM, Emmanuel Lambert
>> <emmanuel.lambert at intec.ugent.be> wrote:
>> > Hello Sean
>> >
>> > Thanks for you reply. I was also just about to add a follow-up comment.
>> >
>> > I upgraded my system to GEOS 3.2.2 (compile from source) and apparently
>> > that solved the problem. So I guess it was an issue of libgeos.
>> > Can I assume that Shapely 1.2.1 works fine with GEOS 3.2.2 ?
>> > I experience no issues at this time, but would appreciate your feedback
>> > on this.
>> >
>> > wbr
>> > Emmanuel
>> >
>> >
>> > On Fri, 2010-06-25 at 12:46 +0200, Sean Gillies wrote:
>> >> 2010/6/24 Emmanuel Lambert <emmanuel.lambert at intec.ugent.be>:
>> >> > Hi,
>> >> >
>> >> > Attached is a list of polygons in WKT format.
>> >> > I have a MultiPolygon consisting of these polygons.
>> >> >
>> >> > The cascaded_union function failes on this multipolygon.
>> >> > "ValueError: No Shapely geometry can be created from null value"
>> >> >
>> >> > Script to reproduce the problem :
>> >> >
>> >> > from shapely.wkt import loads
>> >> > from shapely.geometry import Polygon,MultiPolygon
>> >> > from shapely.ops import cascaded_union
>> >> >
>> >> > f = open('MULTIPOLYGON.TXT','r')
>> >> > polygons = []
>> >> > while True:
>> >> > wkt = f.readline().replace("\n","")
>> >> > print wkt
>> >> > if len(wkt)==0:
>> >> > break
>> >> > pol = loads(wkt)
>> >> > polygons.append(pol)
>> >> >
>> >> > mp = MultiPolygon(polygons)
>> >> > up = cascaded_union(mp)
>> >> >
>> >> > I have tried several strategies to work around it, but cannot get to a
>> >> > solution. Is this a bug in shapely, or is something wrong with my data?
>> >> > Your advice would be appreciated.
>> >> >
>> >> > (Shapely 1.2.1)
>> >> >
>> >> > Thanks,
>> >> >
>> >> > Emmanuel
>> >> >
>> >>
>> >> Hi Emmanuel,
>> >>
>> >> Before I try to reproduce this, can you run the script again and
>> >> assert that each polygon is valid within the loop?
>> >>
>> >> pol = loads(wkt)
>> >> assert pol.is_valid
>> >> polygons.append(pol)
>> >>
>> >
>> >
>> >
>>
>>
>>
>
>
>
--
Sean
More information about the Community
mailing list