[GIS] cartopy: plotting shapefiles

cartopymatplotlibpythonshapefileshapely

I am new to gis and am trying to plot a shapefile containing land polygons. (From OSM.) Unfortunately my output image is always empty (i.e. white). Can somebody tell me what I am doing wrong?

import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cartopy.io.shapereader import Reader
from cartopy.feature import ShapelyFeature

fname = r'simplified-land-polygons-complete-3857\simplified_land_polygons.shp'

ax = plt.axes(projection=ccrs.Robinson())
shape_feature = ShapelyFeature(Reader(fname).geometries(),
                                ccrs.PlateCarree(), edgecolor='black')
ax.add_feature(shape_feature)
plt.show()

Best Answer

You can add edge or face color to the feature

ax.add_feature(shape_feature, facecolor='blue')
Related Question