ResidentMario / geoplot

High-level geospatial data visualization library for Python.
https://residentmario.github.io/geoplot/index.html
MIT License
1.14k stars 95 forks source link

Voronoi plot with duplicate points fails with unhelpful message #192

Closed arnsholt closed 4 years ago

arnsholt commented 4 years ago

Using geoplot 0.4.0 from Conda.

I spent some time debugging an issue I had with the Voronoi plot, which turned out to be duplicate points in my input data. In this case the number of Voronoi regions is different from the number of input points, which breaks the plotting code (concretely VoronoiPlot.draw() fails on lines 1589-1591, where it tries to assign a series shorter than the target dataframe). I'm not sure if there's a way to handle this case gracefully, but I'd suggest a more informative error message; for example adding something like this at the end of build_voronoi_polygons():

if len(df) != len(polygons):
    raise ValueError('Voronoi diagram has different number of cells than input points, aborting. Maybe you have duplicate points?')
ResidentMario commented 4 years ago

Hey, thanks for reporting this issue! Yes, geoplot definitely needs a more informative error message for this very common failure case. I've added an explicit error to the code (albeit in a slightly different place) in PR 193.