Python basemap stereographic map
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.
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 eg:
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)
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.
链接地址: http://www.djcxy.com/p/55752.html下一篇: Python底图立体图