On 5/4/10 2:03 PM, Timothy W. Hilton wrote:
> Hello matplotlib users,
>
> I am having trouble understanding the coordinate transformations in
> Basemap and pyproj.  I have gridded MODIS vegetation data, with upper
> left corner and lower right corner given in projection coordinates
> (meters).  I want to contour the data with Basemap.  The data are in a
> sinusoidal projection, but the coordinates do not correspond to what
> Basemap seems to expect.
>
> The code below illustrates the problem.  Proj translates the upper
> left to lat/lon correctly (-92.327237416031437, 30.141972433747089),
> while Basemap does not.
>
> #-------- code --------
> from mpl_toolkits.basemap import Basemap
> from mpl_toolkits.basemap import pyproj
>
> ulm = [-8895604.1573329996, 3335851.5589999999]  #upper left, meters
> lrm = [-7783653.6376670003, 2223901.0393329998]  #lower right, meters
>
> sinu = pyproj.Proj(proj='sinu', lon_0=0.0, x_0=0.0, y_0=0.0)
> m = Basemap(projection='sinu', resolution=None, lon_0=0.0)
>
> print "ULM: " + str(ulm)
> print "Proj: " + str(sinu(ulm[0], ulm[1], inverse=True))
> print "Basemap: " + str(m(ulm[0], ulm[1], inverse=True))
> #----- end code --------
>
> This gives:
> ULM: [-8895604.1573329996, 3335851.5589999999]
> Proj: (-92.327237416031437, 30.141972433747089)
> Basemap: (-159.99950210056144, -59.99995206181125)
>
> I'm sure I'm missing something really simple, but I've read a lot of
> documentation and I'm not sure what.
>
> Many thanks for any help.
>
> Best,
> Tim
>    

Tim:  Basemap is using pyproj under the hood, but only supports a subset 
of possible proj4 projections.  The basemap sinusoidal projection is 
global - you can't specify a subregion of the globe.  I think that's 
where the discrepancy is coming from.  I'm sure there's a way to plot 
your MODIS data on a global sinusoidal projection - but it will involve 
transforming the coordinates to the Basemap global sinuosidal coordinate 
system.

-Jeff

-- 
Jeffrey S. Whitaker         Phone  : (303)497-6313
Meteorologist               FAX    : (303)497-6449
NOAA/OAR/PSD  R/PSD1        Email  : jeffrey.s.whita...@noaa.gov
325 Broadway                Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web    : http://tinyurl.com/5telg


------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to