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

feature.COASTLINE and feature.LAND plot incorrectly in shifted TransverseMercator projection #2418

Open
luiserino opened this issue Jul 22, 2024 · 0 comments

Comments

@luiserino
Copy link

luiserino commented Jul 22, 2024

Description

I am trying to plot Northern Europe in a specific projection(SWEREF-99).

However, when changing the central_longitude argument of the TransverseMercator projection from 0 to specific numbers (e.g. 10), the Land and coastline features stop plotting correctly. The world is plotted as all land, and some of the coastline jumps across the map:
Broken TransverseMercator Projection

This Github issue stems from a Stackoverflow post where RuthC recommended I add an Issue here.

Code to reproduce

The code producing the image above:

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

fig1 = plt.figure()
display_crs = ccrs.TransverseMercator(central_longitude=10)
ax = fig1.add_subplot(projection=display_crs)
ax.set_global()
ax.add_feature(feature.LAND)
ax.add_feature(feature.COASTLINE)
plt.show()

If the projection is not shifted it works perfectly:

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

fig1 = plt.figure()
display_crs = ccrs.TransverseMercator(central_longitude=0)
ax = fig1.add_subplot(projection=display_crs)
ax.set_global()
ax.add_feature(feature.LAND)
ax.add_feature(feature.COASTLINE)
plt.show()

I am only interested in a smaller region (Northern Europe), so the coastline issues don't bother me as they don't occur there. However, the land is still not plotting correctly even when cropped:

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

fig1 = plt.figure()
display_crs = ccrs.TransverseMercator(central_longitude=10)
ax = fig1.add_subplot(projection=display_crs)
ax.set_extent([2, 30, 54, 72], crs=ccrs.PlateCarree())
ax.add_feature(feature.LAND)
ax.add_feature(feature.COASTLINE)
plt.show()
Full environment definition

Cartopy version

0.23.0

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

No branches or pull requests

2 participants