I need to create a polygon and draw it on the map from GPS coordinates.
The GPS coordinates are taken from the android phone while the land leveler working the crop fields.
The results are not satisfactory.
import geojson
import pandas as pd
from area import area
from geojson import Polygon
df = pd.read_csv('data.csv')
long_coords = df['Longitude'].tolist()
lat_coords = df['Latitude'].tolist()
data = []
for i in range(0, len(long_coords)):
data.append( tuple([long_coords[i],lat_coords[i]]) )
data.append(data[0])
print("Total GPS Coordinates: {}".format(len(data)))
obj = Polygon([data])
print("Total Area : {} ".format(area(obj)))
f = open("data.geojson", "w")
f.write(str(obj))
f.close()
The GeoJSON result is stored in data.geojson:
Not getting the results expected, I want a single polygon with no holes in it.
The result that I expect
The GPS Coordinates CSV File is: data.csv