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

GSHHSFeature not plotting part of the Delaware River #2060

Open
lgarzio opened this issue Jul 1, 2022 · 4 comments
Open

GSHHSFeature not plotting part of the Delaware River #2060

lgarzio opened this issue Jul 1, 2022 · 4 comments

Comments

@lgarzio
Copy link

lgarzio commented Jul 1, 2022

Description

When using cartopy.feature.GSHHSFeature() for plotting higher resolution coastlines, part of the Delaware River in New Jersey (and other rivers, i.e. NY, Chesapeake Bay) are missing in the map (below). The rivers are accurately depicted using cartopy.feature.NaturalEarthFeature() (line commented out in the code below, map below).

I'm getting the warnings noted in issue #1659, but no other warnings or errors:

"Possible issue encountered when converting Shape # 95 to GeoJSON: Shapefile format requires that polygons contain at least one exterior ring, but the Shape was entirely made up of interior holes (defined by counter-clockwise orientation in the shapefile format). The rings were still included but were encoded as GeoJSON exterior rings instead of holes."

Code to reproduce

import cartopy.crs as ccrs
import cartopy.feature as cfeature
import matplotlib.pyplot as plt

extent = [-77, -72, 38, 41.5]
ecolor = 'k'
fig, ax = plt.subplots(figsize=(11, 8), subplot_kw=dict(projection=ccrs.Mercator()))
ax.set_extent(extent)
gl = ax.gridlines(draw_labels=True, linewidth=1, color='gray', alpha=0.5, linestyle='dotted', x_inline=False)
ax.set_facecolor(cfeature.COLORS['water'])

land = cfeature.GSHHSFeature()
#land = cfeature.NaturalEarthFeature('physical', 'land', '10m')
ax.add_feature(land, facecolor='tan', edgecolor=ecolor)

state_lines = cfeature.NaturalEarthFeature(
        category='cultural',
        name='admin_1_states_provinces_lines',
        scale='10m',
        facecolor='none')

ax.add_feature(cfeature.BORDERS, edgecolor=ecolor)
ax.add_feature(state_lines, edgecolor=ecolor)

Packages

cartopy 0.20.3
matplotlib 3.5.2
pyshp 2.3.0
scipy 1.8.1
shapely 1.8.2

Example plots

GSHHSFeature()
test_gshhs

NaturalEarthFeature()
test_naturalearth

@dopplershift
Copy link
Contributor

Are we sure those features are actually present in the GSHHS dataset?

@greglucas
Copy link
Contributor

My goto solution is try installing Fiona, it seems to be more robust about handling shapefiles than pyshp. pip install fiona and try plotting again.

@lgarzio
Copy link
Author

lgarzio commented Jul 1, 2022

I tried installing fiona (v 1.8.21) and ran the code again and got the same result (minus the pyshp errors)

@seagrinch
Copy link

@lgarzio Looks like the Delaware river polygon may have been fixed in the underlying GSHHS dataset? That said, when running your example there are still a few shapefile errors, so it's still probably not perfect everywhere.

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

No branches or pull requests

4 participants