2

Related to this question, I'm trying to colour in a particular country using cartopy. Copying the example in the linked question works fine, but it fails when using an orthographic projection. MWE and image included, and as one can see, Germany does not end up coloured in.

(Shapefile data can be obtained from here.)

import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.io.shapereader as shpreader

_proj = ccrs.Orthographic(0,0)
#_proj = ccrs.PlateCarree()

_deu = list(shpreader.Reader("shapefiles/DEU_adm_shp/DEU_adm0.shp").geometries())

ax = plt.axes(projection=_proj)
ax.coastlines(resolution='10m', color='k', linewidth=1)

ax.add_geometries(_deu, _proj, edgecolor='black', facecolor='gray', alpha=0.5, zorder=10)

plt.show()

enter image description here

Community
  • 1
  • 1
Kieran Hunt
  • 1,738
  • 4
  • 17
  • 29

1 Answers1

2

You need to add the geometries in the correct CRS which for sure is not orthographic. IIRC it is actually plate carrée. Try this:

ax.add_geometries(_deu, ccrs.PlateCarree(), edgecolor='black',
                  facecolor='gray', alpha=0.5, zorder=10)
Stop harming Monica
  • 12,141
  • 1
  • 36
  • 56