Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NaturalEarthFeature is hard-coded to PlateCarree() #2289

Open
dopplershift opened this issue Nov 17, 2023 · 2 comments · May be fixed by #2307
Open

NaturalEarthFeature is hard-coded to PlateCarree() #2289

dopplershift opened this issue Nov 17, 2023 · 2 comments · May be fixed by #2307

Comments

@dopplershift
Copy link
Contributor

Currently the Feature class takes a crs argument at __init__ time; NaturalEarthFeature hard-codes this as PlateCarree(). This is generally fine, as it matches the Natural Earth data. It would be more flexible, though to pull this from the dataset if available, since shapefiles can optionally have a .prj file that contains the CRS in WKT format. We'd need to read that manually for pyshp, but Fiona makes this available as the .crs attribute on the base collection. I've confirmed that the Natural Earth data do include such .prj files.

This is relevant because downstream in MetPy we subclass Feature to provide US counties and states, (now) from the U.S. Census Bureau. These data are lat/lons defined on NAD83 (which uses GRS80) rather than WGS84. Not a huge difference, but always best to use what's in the data when available. The current API of Feature doesn't have a good way to set the correct feature at data load time.

@dopplershift
Copy link
Contributor Author

Enough to read with:

from pyproj import CRS
with open('us_states_500k.prj', 'rt') as fobj:
    crs = CRS.from_wkt(fobj.read())

@dopplershift
Copy link
Contributor Author

To be clear, I think the right way to proceed is:

  • Make sure the CRS information is read in and exposed through Cartopy's shapereader interface
  • Use that to update the internal .crs attribute on Feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant