Last active
May 18, 2020 14:19
-
-
Save dennissergeev/d52c4265db78488ee66bff9ee9797585 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import cartopy.crs as ccrs | |
import cartopy.feature as cfeature | |
from matplotlib.offsetbox import AnchoredText | |
fig = plt.figure(figsize=(10, 10)) | |
ax = fig.add_subplot(111, projection=ccrs.PlateCarree()) | |
# Set extent of the map | |
ax.set_extent([-130, -90, 10, 60], crs=ccrs.PlateCarree()) | |
# Create a feature for States/Admin 1 regions at 1:50m from Natural Earth | |
states_provinces = cfeature.NaturalEarthFeature( | |
category="cultural", | |
name="admin_1_states_provinces_lines", | |
scale="50m", | |
facecolor="none", | |
) | |
ax.add_feature(states_provinces, edgecolor="red") | |
# Create and add a feature for Coastlines at 1:110m from Natural Earth | |
ax.add_feature( | |
cfeature.NaturalEarthFeature( | |
category="physical", | |
name="coastline", | |
scale="110m", | |
facecolor="none", | |
edgecolor="#333333", | |
) | |
) | |
# Show gridlines with labels | |
ax.gridlines(draw_labels=True) | |
# Add a label | |
my_label = AnchoredText("(a) the map", loc=2, prop=dict(size=18, color='b')) | |
ax.add_artist(my_label) | |
# ADD DATA TO THE MAP | |
ax.scatter(lons, lats, facecolor='C0', edgecolor='C9', transform=ccrs.PlateCarree()) |
Thanks Denis! Much appreciated!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want to make a plot with a satellite background a la Google Maps, you can do it in cartopy, here's an example: https://scitools.org.uk/cartopy/docs/latest/gallery/wmts_time.html#sphx-glr-gallery-wmts-time-py
However, I don't get why you would need such a plot - you only need to extract a polygon around the Rockies.
You can do it either manually by making a list of longitudes and latitudes around the Rockies, or you can ask around at the department, maybe someone already has it, ideally as a Shapely polygon. Then you can use this package to create a region mask:
https://regionmask.readthedocs.io/en/stable/notebooks/create_own_regions.html