draw a marker in basemap python

Solutions on MaxInterview for draw a marker in basemap python by the best coders in the world

showing results for - "draw a marker in basemap python"
Veronica
04 Mar 2016
1import matplotlib.pyplot as plt
2import numpy
3from mpl_toolkits.basemap import Basemap
4
5# 1. get data 
6lon = [-122.2416355, -122.2977475, -121.204408, -118.3272612, -119.0194639]
7lat = [37.7652076, 37.88687, 40.2362738, 33.34221, 35.3738712]
8crowd = [8.0, 500.0, 4.0, 44.0, 119.0]
9
10# 2. draw map 
11
12map = Basemap(projection='lcc', resolution='h', 
13            lat_0=37.5, lon_0=-119,
14            width=1E6, height=1.2E6) 
15
16map.drawcoastlines()
17map.drawcountries()
18map.drawstates()
19map.fillcontinents()
20map.drawmapboundary()
21x,y = map(lon, lat)   # convert (long-lat) degrees to map coords
22
23for x1, y1, c in zip(x, y, crowd):
24    # markersize is scale down by /10
25    # need alpha<1 to get some transparency
26    # red color is more appropriate
27    map.plot(x1, y1, 'ro', markersize=c/10., alpha=0.4)
28
29plt.show()
30