1

GEOSVoronoiDiagram is not published in the Shapely API. However, it is available in the newer GEOS libraries. I'm trying to use it with

func = getattr(geos._lgeos, 'GEOSVoronoiDiagram_r')
attr = ftools.partial(func, geos.lgeos.geos_handle)
attr.__name__ = func.__name__
setattr(geos.lgeos, 'GEOSVoronoiDiagram', attr)
geos.lgeos.GEOSVoronoiDiagram.restype = c_void_p
geos.lgeos.GEOSVoronoiDiagram.argtypes = [c_void_p, c_void_p, c_double, c_int]

gc = geom_factory(
    geos.lgeos.GEOSVoronoiDiagram(
        geom._geom,
        env._geom,
        tolerance,
        int(edges)
    )
)
g for g in gc.geoms]

Which is copied from relevant code in Shapely, but that gives the error

ctypes.ArgumentError: argument 4: <type 'exceptions.TypeError'>: Don't know how to convert parameter 4

What am I missing?

1 Answer 1

1

Seems to work by leaving the "partial" away. So,

key = 'GEOSVoronoiDiagram'
func = getattr(geos.lgeos._lgeos, key + '_r')
setattr(geos.lgeos, key, func)
geos.lgeos.GEOSVoronoiDiagram.restype = c_void_p
geos.lgeos.GEOSVoronoiDiagram.argtypes = [c_void_p, c_void_p, c_void_p, c_double, c_int]

and then in the function

gc = geom_factory(
    geos.lgeos.GEOSVoronoiDiagram(
        geos.lgeos.geos_handle,
        geom._geom,
        env._geom,
        tolerance,
        int(edges)
    )
)
return [g for g in gc.geoms]

The default geos is probably also too old, so install with --no-binary and be sure to have a newer geos in the system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.