Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alphashapes & n<4 #111

Closed
ljwolf opened this issue Oct 4, 2018 · 4 comments
Closed

alphashapes & n<4 #111

ljwolf opened this issue Oct 4, 2018 · 4 comments
Milestone

Comments

@ljwolf
Copy link
Member

ljwolf commented Oct 4, 2018

in theory, the "delaunay" triangulation for cases where the number of points is less than 4 is still "known." N=3 is the triangle, n=2 is the line, and n=1 is the point.

as it stands, Qhull will error out when passed a collection with less than four points. It'd be nice if we checked this & returned something sane in these cases, rather than bailing out from qhull.

@ljwolf
Copy link
Member Author

ljwolf commented Oct 4, 2018

I think this is sufficient to ensure that the output is always a polygon:

def safe_ashape(xys, **ashape_kws):
    if xys.shape[0] < 4:
        return ops.cascaded_union([geom.Point(xy) for xy in xys]).convex_hull
    return alpha_shape(xys, **ashape_kws)

@darribas
Copy link
Member

darribas commented Oct 4, 2018

I've ran into this issue too. I think that solution might do it. Just a question, would that return a polygon object?

@ljwolf
Copy link
Member Author

ljwolf commented Oct 4, 2018

Just checked all the input n, and we'd need a buffer(0) to ensure n=1 and n=2 are polygon output:

def safe_ashape(xys, **ashape_kws):
    if xys.shape[0] < 4:
        return ops.cascaded_union([geom.Point(xy) for xy in xys]).convex_hull.buffer(0)
    return alpha_shape(xys, **ashape_kws)

@jGaboardi
Copy link
Member

Addressed in #115

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants