Cartopy behavior when plotting projected data

☆樱花仙子☆ 提交于 2019-12-07 05:36:11

问题


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


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/21864512/cartopy-behavior-when-plotting-projected-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!