Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AttributeError: 'NoneType' object has no attribute 'longitude'
- import matplotlib.pyplot as plt
- from mpl_toolkits.basemap import Basemap
- from geopy.geocoders import Nominatim
- import math
- city_list = list(flight_data["OriginCityName"].unique())
- cities = city_list
- scale = 1
- map = Basemap(width=10000000,height=6000000,projection='lcc',
- resolution=None,lat_1=45.,lat_2=55,lat_0=50,lon_0=-107.)
- plt.figure(figsize=(19,20))
- map.bluemarble()
- # Get the location of each city and plot it
- geolocator = Nominatim()
- for city in cities:
- loc = geolocator.geocode(city)
- if not loc:
- print("Could not locate {}".format(city))
- continue
- x, y = map(loc.longitude, loc.latitude)
- map.plot(x,y,marker='o',color='Red',markersize=5)
- plt.annotate(city, xy = (x,y), xytext=(-20,20))
- plt.show()
- for city in cities:
- loc = geolocator.geocode(city)
- if not loc:
- print("Could not locate {}".format(city))
- continue
- x, y = map(loc.longitude, loc.latitude)
- map.plot(x,y,marker='o',color='Red',markersize=int(math.sqrt(count))*scale)
- plt.annotate(city, xy = (x,y), xytext=(-20,20))
Add Comment
Please, Sign In to add comment