Andre
Andre

Reputation: 115

How to calculate the shape from lon/lat coordinates and draw it with plotly

I have a plotly based map where I am showing several coordinates in a Mapbox scatter plot. Now I want to get a shape from these coordinates and draw a shape on the map.

The coordinates are available as a pandas.Series. Below an extract of the coordinates.

0    [[51.795, 3.363], [51.79483333333334, 3.363], ...
1    [[51.42536, 2.622246666666667], [51.4256883333 ...

How can I get a shape for these coordinates which boundaries are the outmost coordinates of the cluster?

enter image description here

Upvotes: 2

Views: 1067

Answers (1)

Paul Wasilewski
Paul Wasilewski

Reputation: 10372

In geometry, there are basically two main concepts Convex hull and Alpha shape (also called Concave hull) to get the shape of a finite set of points. The following picture should visually describe the differences between them [2].

enter image description here

In case you want to have the convex hull you can use scipy.spatial.ConvexHull [4].

As alternatives to scipy you can also check geopandas and alphashape.

Upvotes: 2

Related Questions