TransWikia.com

Creating concave hull with Python?

Geographic Information Systems Asked by Tim C. on April 27, 2021

I’m trying to follow this tutoriel to do a concave hull script :
Drawing Boundaries In Python

Of course, I drop all steps for plot results. But at the and of my script I have an error.
This is last lines :

edges = set()
edge_points = []

# loop over triangles:
# ia, ib, ic = indices of corner points of the triangle

for ia, ib, ic in tri.vertices:
    pa = coords[ia]
    pb = coords[ib]
    pc = coords[ic]
    # Lengths of sides of triangle
    a = math.sqrt((pa[0]-pb[0])**2 + (pa[1]-pb[1])**2)
    b = math.sqrt((pb[0]-pc[0])**2 + (pb[1]-pc[1])**2)
    c = math.sqrt((pc[0]-pa[0])**2 + (pc[1]-pa[1])**2)
    # Semiperimeter of triangle
    s = (a + b + c)/2.0
    # Area of triangle by Heron's formula
    area = math.sqrt(s*(s-a)*(s-b)*(s-c))
    circum_r = a*b*c/(4.0*area)
    # Here's the radius filter.
    #print circum_r
    if circum_r < 1.0/alpha:
        add_edge(edges, edge_points, coords, ia, ib)
        add_edge(edges, edge_points, coords, ib, ic)
        add_edge(edges, edge_points, coords, ic, ia)

m = geometry.MultiLineString(edge_points)
triangles = list(polygonize(m))
return cascaded_union(triangles), edge_points

And it returns :

Assertion failed: (!static_cast<bool>("should never be reached")),
function itemsTree, file AbstractSTRtree.cpp, line 373.
Abort trap: 6

What is wrong here?

One Answer

Like it's said here in Workaround 2, you have to import shapely first and fiona after.

For me it solves issue.

Correct answer by Tim C. on April 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP