I have the vertices of a non-self-intersecting polygon in 2-D where the x-coordinate is centred longitude and y-coordinate is centred latitude. I want to find the edges of the polygon.
I can plot the vertices and see which vertices are neighbouring and see the edges. But my question is how can I get these edges.
For example, I am considering the sample data:
> data1
vertices lon lat
5 1.133179 1.027886
4 1.094459 1.013952
2 1.055672 1.000000
1 1.000000 1.028578
3 1.038712 1.042541
6 1.116241 1.070438
Sample Plot of the points is
I want to have an array like this
>edges
ind1 ind2
[1,] 5 6
[2,] 1 3
[3,] 3 6
[4,] 1 2
[5,] 2 4
[6,] 4 5
I am interested about this kind of shape of the polygon (with minimum area)
I got this array by using a function ashape
of the R-package alphahull
. But in this function Euclidean distance is used to find distance between points, which not applicable in my case (since I am considering data on (lon, lat), we can use distHaversine
distance function in the package geosphere
). And this function giving unsatisfactory result in case if the polygon has large number vertices and have complex shape. This polygon may or may not be convex.
Now all I want is to build an algorithm to find the edges of the non-intersecting polygon with minimum area.
Any help in this direction will be gratefully appreciated.