http://wiki.openstreetmap.org/wiki/EPSG:3857
This would be really usefull.
I thought that was what cartopy.crs.Mercator.GOOGLE was? Do you need something different?
(see: https://github.com/SciTools/cartopy/blob/master/lib/cartopy/crs.py#L1008)
Then it's a matter of documentation
How should I as a user have found this?
That's a good question. It is not well documented... Probably worth opening a ticket for this to be documented better.
Another option is to use the cartopy.crs.epsg function (which requires an internet connection) to generate the correct projection directly from the EPSG code:
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
proj = ccrs.epsg(3857)
ax = plt.axes(projection=proj)
ax.coastlines()
plt.show()
Stumbled across this while troubleshooting plotting polygons from a shape file. It appears to me that cartopy.crs.Mercator.GOOGLE and cartopy.crs.epsg(3857) are not the same thing, despite a lot of places on the web stating that the "google projection", "mercator web projection" and EPSG 3857 are one and the same. On my system:
import cartopy.crs as ccrs
print('ccrs.epsg(3857)')
print(ccrs.epsg(3857).proj4_params)
print('ccrs.Mercator.GOOGLE')
print(ccrs.Mercator.GOOGLE.proj4_params)
results in
ccrs.epsg(3857)
{'a': '6378137', 'lat_ts': '0.0', 'lon_0': '0.0', '': None, 'b': '6378137', 'nadgrids': '@null', 'x_0': '0.0', 'wktext': None, 'units': 'm', 'proj': 'merc', 'y_0': '0', 'k': '1.0', 'ellps': 'WGS84', 'no_defs': None}
ccrs.Mercator.GOOGLE
{'a': 6378137.0, 'lon_0': 0.0, 'units': 'm', 'b': 6378137.0, 'k': 1, 'nadgrids': '@null', 'proj': 'merc'}
More significantly, this shape file shows up in slightly different locations depending on which projection I use in this code:
"""modified from https://gis.stackexchange.com/questions/259831/shapefiles-wont-display-with-cartopy
"""
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import cartopy.io.shapereader as shpreader
import matplotlib.pyplot as plt
fname = r'/Users/tim/work/Data/Redwoods/Redwood_SequoiaSempervirens_extentNorthAmerica/data/commondata/data0/sequsemp.shp'
rw_shapes = list(shpreader.Reader(fname).geometries())
# these two lines cause the shapes to show up in slightly different locations. ccrs.Mercator.GOOGLE plots correctly; ccrs.epsg(3857) does not.
# proj = ccrs.epsg(3857)
proj = ccrs.Mercator.GOOGLE
fig = plt.figure(figsize=(12, 12))
ax = plt.axes(projection=ccrs.PlateCarree())
ax.coastlines(resolution='10m')
states_provinces = cfeature.NaturalEarthFeature(
category='cultural',
name='admin_1_states_provinces_lines',
scale='10m',
facecolor='none')
ax.add_feature(states_provinces, edgecolor='grey')
ax.add_geometries(geoms=rw_shapes, crs=proj,
edgecolor='blue', facecolor='blue')
ax.set_extent((-125, -118, 32, 49.2))
plt.show()
Most helpful comment
How should I as a user have found this?