Python底图立体图

发布于 2024-12-12 03:02:26 字数 532 浏览 0 评论 0原文

我想在立体地图上显示一些值(在本例中为南极(spstere))。如果我将它们显示在圆柱形地图(cyl)上,一切都很好:

m = Basemap(projection='cyl',llcrnrlon=-180,llcrnrlat=-90,urcrnrlon=180,urcrnrlat=90,resolution='i') 
CS = m.scatter(lon2,lat2,c=BT2,edgecolors='none',s=sz,cmap='gray')

现在我想在南极立体图上使用相同的值,但我无法让它工作:

m = Basemap(projection='spstere',boundinglat=-10,lon_0=180,resolution='c')
CS = m.scatter(lon2,lat2,c=BT2,edgecolors='none',s=sz,cmap='gray')

无论我做什么,我都只得到绘制了大陆,但没有数据。

I want to display some values on a stereographic map (in this case southpole (spstere)). If I display them on a cylindric map (cyl) everything is fine:

m = Basemap(projection='cyl',llcrnrlon=-180,llcrnrlat=-90,urcrnrlon=180,urcrnrlat=90,resolution='i') 
CS = m.scatter(lon2,lat2,c=BT2,edgecolors='none',s=sz,cmap='gray')

Now I want the same values on the southpole stereographic map, but I cant get it to work:

m = Basemap(projection='spstere',boundinglat=-10,lon_0=180,resolution='c')
CS = m.scatter(lon2,lat2,c=BT2,edgecolors='none',s=sz,cmap='gray')

What ever I do I only get the continents drawn, but no data.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

惟欲睡 2024-12-19 03:02:26

所以我想我自己已经找到了答案。您需要做的是将圆柱投影的纬度/经度坐标转换为属于球极投影的 x/y 坐标。这非常简单,在像这样定义底图之后:

m = Basemap(projection='spstere',boundinglat=-10,lon_0=180,resolution='c')

只需进行这样的转换:

x,y = m(lon2,lat2)

最后用 x/y 坐标绘制地图,例如:

CS = m.scatter(x,y,c=BT2,edgecolors='none',s=sz,cmap='gray')

这对我有用:)

So I think I have found the answer myself. What you need to do is to convert the lat/lon coordinates from the cylindrical projection into x/y coordinates belonging to the stereographic projection. This is quite simple, after defining the Basemap like this:

m = Basemap(projection='spstere',boundinglat=-10,lon_0=180,resolution='c')

just do the conversion like this:

x,y = m(lon2,lat2)

and finally draw the map with the x/y coordinates e.g.:

CS = m.scatter(x,y,c=BT2,edgecolors='none',s=sz,cmap='gray')

This works for me :)

正如您似乎已经弄清楚的那样,您需要将 x 和 y 坐标转换为“地图”坐标(可以在 http://matplotlib.github.com/basemap/users/mapcoords.html):

spstereo = Basemap(projection='spstere',boundinglat=-10,lon_0=180,resolution='c')
x, y = spstereo(lons, lats)
spstereo.scatter(x, y)

As you seem to have already figured out, you need to transform your x and y coordinates into "map" coordinates (the appropriate documentation can be found at http://matplotlib.github.com/basemap/users/mapcoords.html):

spstereo = Basemap(projection='spstere',boundinglat=-10,lon_0=180,resolution='c')
x, y = spstereo(lons, lats)
spstereo.scatter(x, y)
情绪少女 2024-12-19 03:02:26

latlon 关键字即可

m = Basemap(projection='spstere',boundinglat=-10,lon_0=180,resolution='c')
CS = m.scatter(lon2,lat2,c=BT2,s=sz,cmap='gray', latlon=True)

只需添加文档中的

如果 latlon 关键字设置为 True,则 x,y 被解释为经度和纬度(以度为单位)。数据和经度会自动移动以匹配圆柱和伪圆柱投影的地图投影区域,并且 x,y 会转换为地图投影坐标。如果 latlon 为 False(默认),则假定 x 和 y 为地图投影坐标。

Just add the latlon keyword

m = Basemap(projection='spstere',boundinglat=-10,lon_0=180,resolution='c')
CS = m.scatter(lon2,lat2,c=BT2,s=sz,cmap='gray', latlon=True)

from the documentation:

If latlon keyword is set to True, x,y are intrepreted as longitude and latitude in degrees. Data and longitudes are automatically shifted to match map projection region for cylindrical and pseudocylindrical projections, and x,y are transformed to map projection coordinates. If latlon is False (default), x and y are assumed to be map projection coordinates.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文