Baseline drawing line between latitude longitudes

I am drawing the start / end locations for a tornado. The csv file has data such that:

TouchDownLat TouchDownLong LiftoffLat LiftoffLong
31.53         -97.15       31.74      -96.88
46.45         -100.67      46.67      -100.47
43.1          -83.85       43.17      -83.42

      

etc...

What I did was take each latitude and longitude and split it into a numpy array as such:

import matplotlib.pyplot as plt
import csv
import numpy as np
from mpl_toolkits.basemap import Basemap
with open(fname, 'rb') as f:
    w = csv.reader(f, delimiter = ',')
    for i, line in enumerate (w):
      if i == 0 or line[2][0:4] not in str(range(2007,2018)):
          pass
      else:
          lat_td.append(line[27])
          long_td.append(line[28])
          lat_lift.append(line[29])
          long_lift.append(line[30])

touchdown = np.array([[lat_td], [long_td]])
lift = np.array([[lat_lift], [long_lift]])

      

For the basemap, I find the max / min for the whole lat / long, so it makes the map to cut out states that did not have a tornado (for example: I don't want to see California when looking at EF-5 tornado locations)

m = Basemap(projection = 'merc', llcrnrlat=float(min(lat_td)) - 2,\
    urcrnrlat=float(max(lat_lift)) + 2, llcrnrlon=float(max(long_td)) - 2,\
    urcrnrlon=float(min(long_lift)) + 2,lat_ts=40,resolution='l')
m.drawcoastlines()
m.fillcontinents(color='white')
m.drawmapboundary(fill_color='white')
m.drawstates(color='black')
m.drawcountries(color='black')
plt.title("#wedgez")

      

So now the question is: I am looking to plot a tornado track using lat / long on a numpy array. How can i do this?

+3


source to share


1 answer


If I understand correctly, you are looking for a way to plot the path given the coordinates of the path points. Then you can build the path like this:



m = Basemap(projection = 'merc', llcrnrlat=float(min(lat_td)) - 2,\
    urcrnrlat=float(max(lat_lift)) + 2, llcrnrlon=float(max(long_td)) - 2,\
    urcrnrlon=float(min(long_lift)) + 2,lat_ts=40,resolution='l')

lat = [the list of lat coordinates here] 
lon = [the list of lon coordinates here] 

x, y = m(lon, lat)
m.plot(x, y, 'o-', markersize=5, linewidth=1) 

m.drawcoastlines()
m.fillcontinents(color='white')
m.drawmapboundary(fill_color='white')
m.drawstates(color='black')
m.drawcountries(color='black')
plt.title("#wedgez")
plt.show() 

      

+4


source







All Articles