Could basemap plot in a UTM projection? - pyproj documentation

Hi,

I've been trawling round the internet for a while trying to work out

if basemap could be made to plot using a UTM zone projection. I’ve
found some references to pyproj that could be used to convert out of
a UTM projection, but I haven’t found any references to defining a
custom projection for basemap. Is it possible?

Also, there is not a lot of documentation regarding pyproj and I

find this a little odd considering it comes packaged with basemap.

Many Thanks,

Mat
···


Dr. Mathew Topper

  Institute for Energy Systems

  School of Engineering

  The University of Edinburgh

  Faraday Building

  The King’s Buildings

  Edinburgh EH9 3JL

  Tel: +44 (0)131 650 5570

  School fax: +44 (0)131 650 6554

  mathew.topper@...3926...

  [http://www.see.ed.ac.uk](http://www.see.ed.ac.uk/)

Mat: Basemap can plot in the tranverse mercator projection
(projecton=‘tmerc’) - UTM zones are transverse mercator with
specific lat/lon boundaries and a WGS84 ellipsoid. I suppose I could
add UTM zone support if there is enough demand for it.

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

Jeffrey.S.Whitaker@…259…http://tinyurl.com/5telg

OK, thanks Jeff. So I just need to know the lon/lat bounds of the
desired UTM zone and I have effectively created a UTM projection of
that zone in basemap i.e. for UTM29 we have 12W to 6W.

  Will basemap then except coordinates in meters defined by UTM29 or

do I have to convert to lon/lat first?

  I have a bit of an interesting case where the region we are

examining lies between UTM29 and UTM30, and I was interested in
displaying how the change in projection effects the topography.

  Thanks

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

Jeffrey.S.Whitaker@…259…http://tinyurl.com/5telg

Dr. Mathew Topper

  Institute for Energy Systems

  School of Engineering

  The University of Edinburgh

  Faraday Building

  The King’s Buildings

  Edinburgh EH9 3JL

  Tel: +44 (0)131 650 5570

  School fax: +44 (0)131 650 6554

  mathew.topper@...3926...

  [http://www.see.ed.ac.uk](http://www.see.ed.ac.uk/)

Sorry, somehow the bottom of the last email I sent was in a funny
format. Sorry to everyone for spamming this, but just in case it
wasn’t legible, here it is again…

OK, thanks Jeff. So I just need to know the lon/lat bounds of the

desired UTM zone and I have effectively created a UTM projection of
that zone in basemap i.e. for UTM29 we have 12W to 6W.

Will basemap then except coordinates in meters defined by UTM29 or

do I have to convert to lon/lat first?

I have a bit of an interesting case where the region we are

examining lies between UTM29 and UTM30, and I was interested in
displaying how the change in projection effects the topography.

Thanks

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

Jeffrey.S.Whitaker@…259…http://tinyurl.com/5telg

Dr. Mathew Topper

  Institute for Energy Systems

  School of Engineering

  The University of Edinburgh

  Faraday Building

  The King’s Buildings

  Edinburgh EH9 3JL

  Tel: +44 (0)131 650 5570

  School fax: +44 (0)131 650 6554

  mathew.topper@...3926...

  [http://www.see.ed.ac.uk](http://www.see.ed.ac.uk/)

Hi,

      I've been trawling round the internet for a while trying to

work out if basemap could be made to plot using a UTM zone
projection. I’ve found some references to pyproj that could be
used to convert out of a UTM projection, but I haven’t found
any references to defining a custom projection for basemap. Is
it possible?

      Also, there is not a lot of documentation regarding pyproj and

I find this a little odd considering it comes packaged with
basemap.

      Many Thanks,



      Mat
    Mat:  Basemap can plot in the tranverse mercator projection

(projecton=‘tmerc’) - UTM zones are transverse mercator with
specific lat/lon boundaries and a WGS84 ellipsoid. I suppose I
could add UTM zone support if there is enough demand for it.

    -Jeff
  OK, thanks Jeff. So I just need to know the lon/lat bounds of the

desired UTM zone and I have effectively created a UTM projection
of that zone in basemap i.e. for UTM29 we have 12W to 6W.

    Will basemap then except coordinates in meters defined by UTM29

or do I have to convert to lon/lat first?

Mat:  If you use projection='tmerc' and then give the lat/lon coords

of the upper right and lower left corners with
llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat, the projection coordinates
will be such that x,y = 0 in the lower left corner. Since those
will not match the UTM coordinates exactly, you will have to add an
offset in x,y to make them match.

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

Jeffrey.S.Whitaker@…259…http://tinyurl.com/5telg

Dr. Mathew Topper

    Institute for Energy Systems

    School of Engineering

    The University of Edinburgh

    Faraday Building

    The King’s Buildings

    Edinburgh EH9 3JL

    Tel: +44 (0)131 650 5570

    School fax: +44 (0)131 650 6554

    mathew.topper@...3926...

    [http://www.see.ed.ac.uk](http://www.see.ed.ac.uk/)
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here

http://p.sf.net/sfu/sfd2d-msazure

_______________________________________________
Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/matplotlib-users

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

Jeffrey.S.Whitaker@…259…http://tinyurl.com/5telg

Mat: I just updated git master to add the ‘k_0’ keyword when using
projection=‘tmerc’. This is the scaling factor along the central
meridian, and is needed to exactly match the UTM definition. I also
added a utmtest.py example, that shows how to plot a UTM zone, and
convert Basemap coordinates to UTM coordinates.

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

Jeffrey.S.Whitaker@…259…http://tinyurl.com/5telg

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

Jeffrey.S.Whitaker@…259…http://tinyurl.com/5telg

Jeff, thanks again for all your help with this. I tried the example
and it works great. My only question would be how to get the axis
labels into meters rather than degrees. Any hints? I have found the
customticks.py example. Is that the best route to take?

In other news, I got a crash with run_all.py in the examples

directory:

topper@...4055...: examples $ python run_all.py

Traceback (most recent call last):

  File "run_all.py", line 8, in <module>

    test_files.remove('pnganim.py')

ValueError: list.remove(x): x not in list

Commenting out line 8 sorted that out.

Regards,

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

Jeffrey.S.Whitaker@…259…http://tinyurl.com/5telg

Dr. Mathew Topper

  Institute for Energy Systems

  School of Engineering

  The University of Edinburgh

  Faraday Building

  The King’s Buildings

  Edinburgh EH9 3JL

  Tel: +44 (0)131 650 5570

  School fax: +44 (0)131 650 6554

  mathew.topper@...3926...

  [http://www.see.ed.ac.uk](http://www.see.ed.ac.uk/)

Mat: Just use ‘suppress_ticks=False’ when creating the Basemap
instance, and you will get axis ticks in meters. If you want to use
a custom tick formatter, use the customticks.py example as a guide.

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

Jeffrey.S.Whitaker@…259…http://tinyurl.com/5telg

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

Jeffrey.S.Whitaker@…259…http://tinyurl.com/5telg

Jeff, I wonder whether I could run this past you? Basically, I
believe the easting and northing grid lines are available just by
turning on the standard matplotlib grid, so therefore I’m assuming
that the easting and northing grid will be orthogonal throughout the
map - is that correct?

Assuming all is well with that then I need to add the correct offset

to the axes values, presumably by calculating the value, in meters,
of the origin. I’m guessing I will have to use a tick formatter
(like customticks.py) to do this or the map points will no longer be
on the map (if, for instance, I just changed the axes ranges).

Does that make sense to you?

Thanks

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

Jeffrey.S.Whitaker@…259…http://tinyurl.com/5telg

Dr. Mathew Topper

  Institute for Energy Systems

  School of Engineering

  The University of Edinburgh

  Faraday Building

  The King’s Buildings

  Edinburgh EH9 3JL

  Tel: +44 (0)131 650 5570

  School fax: +44 (0)131 650 6554

  mathew.topper@...3926...

  [http://www.see.ed.ac.uk](http://www.see.ed.ac.uk/)