Countries/ States (NaturalEarth)¶
The outline of the countries are obtained from Natural Earth. They are automatically downloaded on-the-fly (but only once) with cartopy and opened with geopandas. The following countries and regions are defined in regionmask.
Countries 1:110m
Countries 1:50m
US States 1:50m
US States 1:10m
Note
A mask obtained with a fine resolution dataset is not necessarily better. Always check your mask!
The following imports are necessary for the examples.
In [1]: import regionmask
In [2]: import matplotlib.pyplot as plt
Countries¶
In [3]: regionmask.defined_regions.natural_earth.countries_110.plot(add_label=False);
In [4]: plt.tight_layout()
US States¶
In [5]: states = regionmask.defined_regions.natural_earth.us_states_50
In [6]: states.plot(add_label=False);
In [7]: plt.tight_layout()
Also create a mask for a 1° grid over the US:
In [8]: import numpy as np
# create a grid
In [9]: lon = np.arange(200.5, 325)
In [10]: lat = np.arange(74.5, 14, -1)
In [11]: mask = states.mask(lon, lat)
In [12]: states.plot(add_label=False);
In [13]: mask.plot(add_colorbar=False)
Out[13]: <matplotlib.collections.QuadMesh at 0x7fcb40fc5dd0>
In [14]: plt.tight_layout()