Hi all,
First of all, even if I posted several mails about problems with Shapely,
I'd like to say that it's really great to work with Shapely and to thank
Sean and all that are involved !
now ...
I've tried to build "by hand" the buffer of a polygon for which the buffer
method fails (bugs in libgeos) :
- "buffer" method for the polygon, ignoring the inner rings, with + dist
- "buffer" method for each hole with - dist
- iterations with "difference" to add holes to the polygon
This polygon is rather big (more than 300,000 vertices, 920 holes) and the
script below (without the 2 buffering operations that don't change anything)
crashes because of a lack of memory. At the beginning, the process (Python
console) uses less than 200 Mbytes and, after about 700 iterations/holes,
more than 3 Gbytes. I've added explicit "del" statements for temporary
variables, it doesn't matter.
>>> shell=Polygon(tuple(geom.exterior.coords))
>>> for i,inter in enumerate(geom.interiors):
>>> hole=Polygon(tuple(inter.coords))
>>> new_shell = shell.difference(hole)
>>> del hole
>>> del shell
>>> shell = new_shell
>>> print i,"done"
output :
...
728 done
729 done
Python(15285) malloc: *** mmap(size=16777216) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Python(15285) malloc: *** mmap(size=16777216) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
...
...
Python(15285) malloc: *** mmap(size=16777216) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/Shapely-1.0.11-py2.5.egg/shapely/topology.py",
line 34, in __call__
if not self.context.is_valid:
File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/Shapely-1.0.11-py2.5.egg/shapely/predicates.py",
line 56, in __get__
return bool(self.fn(obj._geom))
File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/Shapely-1.0.11-py2.5.egg/shapely/predicates.py",
line 49, in errcheck
raise PredicateError, "Failed to evaluate %s" % repr(self.fn)
shapely.geos.PredicateError: Failed to evaluate <_FuncPtr object at
0xbcef80>
It occurs on MacOSX and Ubuntu for Shapely 1.0.11 and Python 2.5.2.
An equivalent code in C, with a "free" statement (GEOSGeom_destroy) for each
temporary geometry works with a correct result and an amount of used memory
that is OK.
Pascal
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community