When a contextily basemap is added to an axis projected with cartopy, the map appears upside down. Here is a minimum example:
import matplotlib.pyplot as plt
import cartopy
import contextily
# contextily & cartopy
fig, ax = plt.subplots()
ax = plt.axes(projection=cartopy.crs.Mercator())
ax.add_feature(cartopy.feature.COASTLINE)
ax.set_extent([-11,37,35,70])
contextily.add_basemap(ax)
The following code produces a correct map, however, without cartopy features:
# contextily
fig, ax = plt.subplots()
ax.set_xlim(-1163881, 4068715)
ax.set_ylim( 4118821,11118821)
contextily.add_basemap(ax)
It looks like there is some projection issue with the cartopy coordinate system. How to add a proper basemap to a cartopy plot?
I ran into this issue as well... not sure how to resolve this with contextily, but found a solution using the built in cartopy method
ax.add_wmts()
to access and plot basemap tiles.Additional layers can be found here. Just need to swap out the
layer_name
.