How to properly define lat/lon WGS84 in basemap module?

Hi All,

I have some square images which were generated via WMS requests. I have imported them into Matplotlib via pil_to_array, and then display them in a Basemap instance where I have defined the projection as:

m = Basemap(projection=‘cyl’, lon_0=lon_0, llcrnrlon=ll_lon, llcrnrlat=ll_lat, urcrnrlon=ur_lon,
urcrnrlat=ur_lat, suppress_ticks=False)

While this works (it appears the tics are at the right places), the image is no longer square, and I wonder if my projection definition is correct.

Can someone show me what the correct Basemap parameters are for working with images that are in EPSG:4326?

Thanks,

Roger

Roger Andr� wrote:

Hi All,

I have some square images which were generated via WMS requests. I have imported them into Matplotlib via pil_to_array, and then display them in a Basemap instance where I have defined the projection as:

m = Basemap(projection='cyl', lon_0=lon_0, llcrnrlon=ll_lon, llcrnrlat=ll_lat, urcrnrlon=ur_lon,
            urcrnrlat=ur_lat, suppress_ticks=False)

While this works (it appears the tics are at the right places), the image is no longer square, and I wonder if my projection definition is correct.

Can someone show me what the correct Basemap parameters are for working with images that are in EPSG:4326?

Thanks,

Roger

Roger: The image will only be square if ur_lon-ll_lon = ur_lat-ll_lat (i.e. the longitude range equals the latitude range). Is this the case?

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328

Hi Jeff,

I checked, and no the images are not geographically square. I wonder if I could approach this problem in a different way. Would it be possible for me to add tick marks and annotation to the image without using the Basemap module alone? My thinking is that I could bring the image into Matplotlib, define a square figure, and then manually define the size of the X and Y axes and label them. Is it possible to “decorate” an image this way, without using any projection support?

Thanks for the help,

Roger

···

On Tue, Dec 16, 2008 at 4:43 AM, Jeff Whitaker <jswhit@…146…> wrote:

Roger André wrote:

Hi All,

I have some square images which were generated via WMS requests. I have imported them into Matplotlib via pil_to_array, and then display them in a Basemap instance where I have defined the projection as:

m = Basemap(projection=‘cyl’, lon_0=lon_0, llcrnrlon=ll_lon, llcrnrlat=ll_lat, urcrnrlon=ur_lon,

        urcrnrlat=ur_lat, suppress_ticks=False)

While this works (it appears the tics are at the right places), the image is no longer square, and I wonder if my projection definition is correct.

Can someone show me what the correct Basemap parameters are for working with images that are in EPSG:4326?

Thanks,

Roger

Roger: The image will only be square if ur_lon-ll_lon = ur_lat-ll_lat (i.e. the longitude range equals the latitude range). Is this the case?

-Jeff

Jeffrey S. Whitaker Phone : (303)497-6313

NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449

325 Broadway Boulder, CO, USA 80305-3328

Roger André wrote:

Hi Jeff,

I checked, and no the images are not geographically square. I wonder if I could approach this problem in a different way. Would it be possible for me to add tick marks and annotation to the image without using the Basemap module alone? My thinking is that I could bring the image into Matplotlib, define a square figure, and then manually define the size of the X and Y axes and label them. Is it possible to "decorate" an image this way, without using any projection support?

Thanks for the help,

Roger

Roger: Sure, you could do that. I'm not sure why you would want to display an image that's not geographically square as a square though. What's wrong with just letting Basemap show it as a rectange?

-Jeff

···

--

On Tue, Dec 16, 2008 at 4:43 AM, Jeff Whitaker <jswhit@...146... > <mailto:jswhit@…146…>> wrote:

    Roger André wrote:

        Hi All,

        I have some square images which were generated via WMS
        requests. I have imported them into Matplotlib via
        pil_to_array, and then display them in a Basemap instance
        where I have defined the projection as:

        m = Basemap(projection='cyl', lon_0=lon_0, llcrnrlon=ll_lon,
        llcrnrlat=ll_lat, urcrnrlon=ur_lon,
                   urcrnrlat=ur_lat, suppress_ticks=False)

        While this works (it appears the tics are at the right
        places), the image is no longer square, and I wonder if my
        projection definition is correct.

        Can someone show me what the correct Basemap parameters are
        for working with images that are in EPSG:4326?

        Thanks,

        Roger

    Roger: The image will only be square if ur_lon-ll_lon =
    ur_lat-ll_lat (i.e. the longitude range equals the latitude
    range). Is this the case?
    -Jeff

    -- Jeffrey S. Whitaker Phone : (303)497-6313
    NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
    325 Broadway Boulder, CO, USA 80305-3328

--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@...259...
325 Broadway Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web : Jeffrey S. Whitaker: NOAA Physical Sciences Laboratory

Ahh, because I have labels and other text already drawn on the image. Squishing it alters the shape of the letters. And I have potentially many of these coming out of WMS requests where I know the image size and corner coords, but I can’t alter the basic nature of the image. What I’d like to do is use these images as figures in a report, so I need to be able to add Axes with labeling, and also Figure titles and text.

Thanks,

Roger

···

On Tue, Dec 16, 2008 at 9:53 AM, Jeff Whitaker <jswhit@…146…> wrote:

Roger André wrote:

Hi Jeff,

I checked, and no the images are not geographically square. I wonder if I could approach this problem in a different way. Would it be possible for me to add tick marks and annotation to the image without using the Basemap module alone? My thinking is that I could bring the image into Matplotlib, define a square figure, and then manually define the size of the X and Y axes and label them. Is it possible to “decorate” an image this way, without using any projection support?

Thanks for the help,

Roger

Roger: Sure, you could do that. I’m not sure why you would want to display an image that’s not geographically square as a square though. What’s wrong with just letting Basemap show it as a rectange?

-Jeff

On Tue, Dec 16, 2008 at 4:43 AM, Jeff Whitaker <jswhit@…146… mailto:jswhit@...146...> wrote:

Roger André wrote:



    Hi All,



    I have some square images which were generated via WMS

    requests.  I have imported them into Matplotlib via

    pil_to_array, and then display them in a Basemap instance

    where I have defined the projection as:



    m = Basemap(projection='cyl', lon_0=lon_0, llcrnrlon=ll_lon,

    llcrnrlat=ll_lat, urcrnrlon=ur_lon,

               urcrnrlat=ur_lat, suppress_ticks=False)



    While this works (it appears the tics are at the right

    places), the image is no longer square, and I wonder if my

    projection definition is correct.



    Can someone show me what the correct Basemap parameters are

    for working with images that are in EPSG:4326?



    Thanks,



    Roger





Roger:  The image will only be square if ur_lon-ll_lon =

ur_lat-ll_lat (i.e. the longitude range equals the latitude

range).  Is this the case?

-Jeff



--    Jeffrey S. Whitaker         Phone : (303)497-6313

NOAA/OAR/CDC  R/PSD1        FAX   : (303)497-6449

325 Broadway                Boulder, CO, USA 80305-3328

Jeffrey S. Whitaker Phone : (303)497-6313

Meteorologist FAX : (303)497-6449

NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@…259…

325 Broadway Office : Skaggs Research Cntr 1D-113

Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg