Luis
Luis

Reputation: 1

NaturalEarthFeature does not display correctly with certain (distorted) map projections

I am trying to plot a map following a specific map projection (https://www.lantmateriet.se/en/geodata/gps-geodesi-och-swepos/transformations/RT-90---SWEREF-99/). The projection is a specific Transverse Mercator projection. When using the projection, the LAND Natural Earth feature does not show up correctly (everything is plotted as land). In the following, I have reduced the specific projection from above to what seems to be causing the issue for me: If the projection is shifted by the central longitude by certain amounts (eg. 10 as used below), the map plots as all land.

This show the plot not showing land correctly (everything is gray even if only land should be gray).

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, transform=display_crs)
ax.add_feature(feature.COASTLINE, transform=display_crs)
plt.show()

Transverse mercator broken

The standard Transverse Mercator projection works as intended:

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) # only difference to above version
ax = fig1.add_subplot(projection=display_crs)
ax.set_global()
ax.add_feature(feature.LAND, transform=display_crs)
ax.add_feature(feature.COASTLINE, transform=display_crs)
plt.show()

Transverse Mercator working

The region i am interested in (Northern Europe) is not that distorted. However even when I limit the extent to the smaller region (in which the coastline is fine), the land feature still draws over everything as all gray:

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, transform=display_crs)
ax.add_feature(feature.COASTLINE, transform=display_crs)
plt.show()

Transverse Mercator broken for zoomed in region

Is there a way to fix this? Is there maybe a different way to limit what parts of the land feature are drawn? Thanks!

Upvotes: 0

Views: 49

Answers (0)

Related Questions