我可以旋转一个Cartopy投影以使图像以垂直方向显示感兴趣的国家吗?

huangapple go评论98阅读模式
英文:

Can I rotate a Cartopy Projection to make the figure show the country of interest in the vertical orientation?

问题

我正在进行格陵兰冰盖数据的立体投影。当我绘制投影时,如果没有设置任何属性,格陵兰会稍微倾斜。当我将central_latitude和central_longitude设置为在格陵兰中心时,它会使格陵兰变为水平。我需要垂直显示图像。我能够旋转整个结果图像,但是颜色条和标题仍然位于图像的长边上。

使用以下代码将得到一个水平的格陵兰

ax = fig.add_axes([0.1,0.1,0.8,0.8], projection=ccrs.Stereographic(central_latitude=42.6043, central_longitude=71.7069))

使用以下代码将得到一个稍微倾斜的格陵兰

ax = fig.add_axes([0.1,0.1,0.8,0.8], projection=ccrs.Stereographic())

使用以下代码旋转整个图像,但不会影响图形,可以在这里看到

angle = 90
out = im.rotate(angle, expand=True)

是否可能旋转投影/图像,以使格陵兰垂直居中?

英文:

I'm doing a Stereographic Cartopy projection of some Greenland ice sheet data. When I plot the projection without any attributes, I get a slightly rotated Greenland. When I set the central_latitude and central_longitude to center over Greenland, it turns Greenland so that it's horizontal. I need to display the figure vertically. I'm able to rotate the entire resulting image but then the colorbar and title are still along the long sides of the figure.

ax = fig.add_axes([0.1,0.1,0.8,0.8], projection=ccrs.Stereographic(central_latitude=42.6043, central_longitude=71.7069)) gives a horizontal Greenland

ax = fig.add_axes([0.1,0.1,0.8,0.8], projection=ccrs.Stereographic() gives a slightly rotated Greenland

Using

angle = 90

out = im.rotate(angle, expand=True)

just rotates the entire image, not the figure, seen here

Is it possible to rotate the projection/figure so that Greenland is centered vertically?

答案1

得分: 1

你尝试的操作是正确的,但你的坐标似乎有问题。格陵兰岛的纬度不是42,经度也不是71。你指定的点位于吉尔吉斯斯坦西北部的某个地方:https://www.google.com/maps/@42.604,71.707,12z

也许你颠倒了经度和纬度,并假设经度42表示西经?常见方式 表示经度为东经正值,西经为负值,这也是 Cartopy 所采用的方式,因此格陵兰岛的42W 应该指定为 -42。

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

projection = ccrs.Stereographic(central_latitude=70, central_longitude=-42)

fig, ax = plt.subplots(
    figsize=(6, 12), facecolor="w",
    subplot_kw=dict(projection=projection),
)

ax.coastlines()
ax.gridlines(draw_labels=True)
ax.set_extent((-65, -15, 58, 84), crs=ccrs.PlateCarree())

我可以旋转一个Cartopy投影以使图像以垂直方向显示感兴趣的国家吗?

英文:

What you're trying to do is correct, but your coordinates seem off. Greenland is not located at a latitude of 42 nor at a longitude of 71. The point you specify is somewhere in the North West of Kyrgyzstan:
https://www.google.com/maps/@42.604,71.707,12z

Perhaps you flipped longitude and latitude, and assumed that the longitude of 42 means west? The common way to express longitude to be positive for east and negative for west, which is also what Cartopy does, so for Greenland 42W should be specified as -42 instead.

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

projection = ccrs.Stereographic(central_latitude=70, central_longitude=-42)

fig, ax = plt.subplots(
    figsize=(6, 12), facecolor="w",
    subplot_kw=dict(projection=projection),
)

ax.coastlines()
ax.gridlines(draw_labels=True)
ax.set_extent((-65, -15, 58, 84), crs=ccrs.PlateCarree())

我可以旋转一个Cartopy投影以使图像以垂直方向显示感兴趣的国家吗?

huangapple
  • 本文由 发表于 2023年6月22日 03:40:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76526611.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定