Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 213
red_tiger Avatar asked Oct 25 '11 13:10

red_tiger


1 Answers

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 :)

like image 95
red_tiger Avatar answered Oct 20 '22 03:10

red_tiger