I\'m trying to plot the outline of Bay Area city/town borders on top of a cartopy terrain map using a shapefile obtained here and following this example. For some reason, th
As @ImportanceOfBeingErnest and @swatchai suggest, the CRS (coordinate reference system) parameter in ShapelyFeature cartopy.feature.ShapelyFeature()
was incorrect.
The proper EPSG (European Petroleum Survey Group?) code can be found in one of the .xml files included with the shapefile:
<gco:CharacterString>26910</gco:CharacterString>
</code>
<codeSpace>
<gco:CharacterString>EPSG</gco:CharacterString>
and passing this as the second parameter in ShapelyFeature()
is all it takes to get the shapefile to plot the city borders properly:
# Add city borders
filename = r'./shapefile/ba_cities.shp'
shape_feature = ShapelyFeature(Reader(filename).geometries(), ccrs.epsg(26910),
linewidth = 1, facecolor = (1, 1, 1, 0),
edgecolor = (0.5, 0.5, 0.5, 1))
ax.add_feature(shape_feature)
plt.show()