Python basemap stereographic map
Asked Answered
B

3

8

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.

Beriberi answered 25/10, 2011 at 13:16 Comment(1)
You should post your solution as an answer below.Demand
B
3

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

Beriberi answered 15/6, 2012 at 8:3 Comment(0)
R
1

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)
Rael answered 14/6, 2012 at 20:53 Comment(0)
E
0

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.

Endurance answered 17/3, 2015 at 9:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.