Using basemap to generate xyz format files from netcdf files

Hi,

I was wondering how hard it would be to generate xyz format files

from netcdf files using python-netcdf4 and basemap? It seems that
basemap has the capabilities to do those sort of conversions, but I
am a bit of a novice to map data and I’m not sure what would be the
correct approach to this.

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:

What's an xyz file?

-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

Hi Jeff,

Sorry, an XYZ file is simply an ASCII file which can have either

LON,LAT,HEIGHT entries or Cartesian X,Y,HEIGHT entries. I think I
have confused myself a little here, as all I need to do is print the
LON,LAT,HEIGHT data to a file and I’ve finished, and basemap is not
required for this. The original question was whether once a basemap
had been defined is there an easy way to extract the Cartesian
coordinates to produce an XYZ file containing the Cartesian
coordinates for the chosen projection rather than the geographic
ones?

Thanks

Mat

PS. This is in all in the context of converting data for use in a

software package called MIKE. It sadly lacks the ability to deal
with NetCDF files directly.

···
-- 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 Jeff,

  Sorry, an XYZ file is simply an ASCII file which can have either

LON,LAT,HEIGHT entries or Cartesian X,Y,HEIGHT entries. I think I
have confused myself a little here, as all I need to do is print
the LON,LAT,HEIGHT data to a file and I’ve finished, and basemap
is not required for this. The original question was whether once a
basemap had been defined is there an easy way to extract the
Cartesian coordinates to produce an XYZ file containing the
Cartesian coordinates for the chosen projection rather than the
geographic ones?

  Thanks



  Mat



  PS. This is in all in the context of converting data for use in a

software package called MIKE. It sadly lacks the ability to deal
with NetCDF files directly.

Mat:  If you have the longitudes and latitudes in numpy arrays lons,

lats, and m is a Basemap instance,

x,y = m(lons,lats)

gives you the projection 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

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.

Perfect, Jeff, thanks very much. I guess something like this is
hiding in the documentation somewhere, but I must have failed to
find it.

All the best,

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/)
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


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