user1718097
user1718097

Reputation: 4292

Can the geographic co-ordinate system of a shapefile be identified using Cartopy?

I have a shapefile that I have downloaded onto my local hard drive. I can use Cartopy to read the shapefile and plot a map using Matplotlib as follows:

import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.io.shapereader as shpreader
reader = shpreader.Reader('/path_to_shapefile/myShapeFile.shp')
ax = plt.axes(projection=ccrs.OSGB())
ax.add_geometries(reader.geometries(),ccrs.OSGB(),edgecolor = 'k',facecolor = 'none')
plt.show()

However, I would like to be able to identify the geographic co-ordinate system of the shapefile (e.g. WGS84 or OSGB) so that I can make sure that it matches the co-ordinate values of some points that I want to plot on the same map. Having read the shapefile, I assume that Cartopy can display the coordinate system used but I can't find out how to do so. Can Cartopy do this or do I need to use a different package?

Upvotes: 0

Views: 493

Answers (1)

DopplerShift
DopplerShift

Reputation: 5843

Cartopy is using pyshp under the hood to read the shapefile. As far as I can tell, that library does not provide the information you are looking for. (CartoPy does not expose this information about PyShp anyway.)

Your best bet may be to look at Fiona, which are nice Python bindings for GDAL. You could use this to open the shapefile manually and inspect--I assume this library will provide the information you're looking for, if anything in the Python space does.

Upvotes: 1

Related Questions