Frage

I am using cartopy to draw my maps. Its a great tool! For some of my data I have the problem that the data is not properly mapped around 0deg or the dateline. See the example below.

I know the same feature from matplotlib.basemap, where it can be solved by using the add_cyclic routine. I wondered if somebody can recommend how to best fix this problem in cartopy.

Thanks!

Alex

Cartopy problem

War es hilfreich?

Lösung 2

The cartopy development team has included the required feature in the developoment branch. For details see here

Andere Tipps

When plotting global data like this you will always need to add a cyclic point to your input data and coordinate. I don't believe Cartopy currently includes a function to do this for you, but you can do it yourself quite simply for the time being. Assuming you have a 1d array of longitudes and a 2d array of data where the first dimension is latitude and the second is longitude:

import numpy as np

dlon = lons[1] - lons[0]
new_lons = np.concatenate((lons, lons[-1:] + dlon))
new_data = np.concatenate((data, data[:, 0:1]), axis=1)

If you have different shaped data or coordinates then you will need to adjust this to your needs.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top