I have a database with the following structure:

lat lon id
19.7 -95.2 1
19.7 -94.7 1
19.3 -93.9 1
19 -93.5 1
19 -92.8 1
19.2 -92.6 1
19.9 -93 1
20 -92.8 1
23.1 -100.2 2
23.2 -100 2
23.3 -100 2
23.3 -100.2 2
23.4 -99 2
23.5 -98.9 2
23.6 -98.7 2
23.7 -98.8 2

The question is: how I can plot the trajectories associated with each id?. I made a script like this:

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np

# Draw map

m = Basemap(projection='lcc', llcrnrlat=12, urcrnrlat=34,llcrnrlon=-115, urcrnrlon=-80,lat_1=20, lat_2=30,lon_0=-100, resolution='h', area_thresh=1000.) 
m.drawcoastlines()
m.drawcountries()
m.drawmapboundary(fill_color='aqua')
m.fillcontinents(color='coral')
m.drawstates()
Dibujamos Paralelos y Meridianos
m.drawparallels(np.arange(10,70,10), labels=[False,True,True,False])
m.drawmeridians(np.arange(-140,-70,10), labels=[True,False,False,True])

# Read data
f = file('path-tracks.csv','r')
line = f.readline()
line = f.readline()
lat=[]
lon=[]
evento=[]
while line:
    data = line.split(',')
    lat.append(float(data[0]))
    lon.append(float(data[1]))
    evento.append(str(data[3]))
    line = f.readline()
for e, la, lo in zip(lon, lat, id):
    x, y = m(lon, lat)

plt.show()

when running the script generates a figure with a line connecting all points and I would like to get a picture with the three trajectories, How I can achieve this?

Sorry, i would like to get a picture with the two trajectories...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.