I have a CSV file which has the latitude and longitude values for the start and the end coordinates as follows. In these the first lon and lat values are the start point then the second coordinates are the end points for one value. Then the third point is the start and the forth is the end and so on. The csv is in the following format
lat lon
1.25 6.45
2.45 5.36
3.67 9.67
3.56 6.25
The code which I tried is:
def main(interval,azimuth,lat1,lng1,lat2,lng2):
'''returns every coordinate pair inbetween two coordinate
pairs given the desired interval'''
d = getPathLength(lat1,lng1,lat2,lng2)
remainder, dist = math.modf((d / interval))
counter = float(interval)
coords = []
coords.append([lat1,lng1])
for distance in range(0,int(dist)):
coord = getDestinationLatLong(lat1,lng1,azimuth,counter)
counter = counter + float(interval)
coords.append(coord)
coords.append([lat2,lng2])
return coords
if __name__ == "__main__":
#point interval in meters
interval = 10
#direction of line in degrees
#start point
lat1 = 18.750000000
lng1 = 85.416666667
#end point
lat2 = 17.650000000
lng2 = 83.250000000
azimuth = calculateBearing(lat1,lng1,lat2,lng2)
#print(azimuth)
azimuth
coords = main(interval,azimuth,lat1,lng1,lat2,lng2)
#print(coords)
coords
This code takes the coordinates manually but I need it to take values from CSV and generate the output as CSV.
csv module
for this.