-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathexample_plot_usa_map.py
45 lines (35 loc) · 1.03 KB
/
example_plot_usa_map.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""
Make map of CONUS
"""
from global_land_mask import globe
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
# Lat/lon points to get
lat = np.linspace(-20,90,1000)
lon = np.linspace(-130,-60,1002)
# Make a grid
lon_grid, lat_grid = np.meshgrid(lon,lat)
# Get whether the points are on land.
z = globe.is_land(lat_grid, lon_grid)
# Set up map
fig = plt.figure(0, figsize=(5.5, 4.5))
plt.clf()
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])
m = Basemap(llcrnrlon=-119, llcrnrlat=22, urcrnrlon=-64, urcrnrlat=49,
projection='lcc', lat_1=33, lat_2=45, lon_0=-95,
area_thresh=200,
resolution='i')
m.drawstates(linewidth=0.2)
m.drawcoastlines(linewidth=0.2)
m.drawcountries(linewidth=0.2)
cs = m.contourf(lon_grid, lat_grid, z,
levels=[-0.5, 0.5,1.5],
cmap="jet",
latlon=True)
plt.show()
plt.savefig('example_plot_globe_map_us.png',
bbox_inches='tight',
dpi=400)