Re: Converting ASCII Grids to NetCdf


Another approach would be to use the fabulous GDAL package

which makes converting the Arc/Info ASCII grid to netcdf (GMT conventions) as easy as:

  gdal_translate arc_ascii.grd -of GMT

GDAL can convert between these formats:

GDAL can read CF NetCDF grids as well, but it looks like it doesn't (yet?) support writing CF-compliant NetCDF. Perhaps someone from the Galeon project knows more about the plans for GDAL & CF.

The easiest way (and what I do) to get GDAL built with all the goodies is download "FWTOOLS" from

which is a complete binary distribution for both Linux and PC containing GDAL as well as Python, OpenEv, Mapserver.

Richard P. Signell
U.S. Geological Survey       Phone: (508) 457-2229
384 Woods Hole Road          Fax:   (508) 457-2310
Woods Hole, MA  02543-1598

Don Murray wrote:
Hi Andrew-

Chase, Andrew wrote:

Hi Folks,

I'm trying to do something relatively simple, but I haven't been able to
find any examples of others doing it before me. Just thought I'd ask
here before going off and writing the code myself.
What I want to do is take a DEM stored in the  ESRI ASCII Raster format
and convert it to a netcdf file. My ascii raster has the standard header
format like so:
ncols         5001
nrows         4001
xllcorner     -125
yllcorner     34
cellsize      0.001
NODATA_value  -9999

Anybody got some code to do this? :-)

If not, no biggee, just thought I'd ask.

The best way to do this would be to write an IO Service Provider
(IOSP) layer that would read in the file and create the netCDF
object.  I'm not sure if there is any documentation on this,
but there are some other examples that you could probably follow.

There is code in VisAD to read in the ASCII Arc Grid format
into VisAD Data objects and it could be adapted to use for this
task.  The source code is available at:

in the reader.  It does not
handle any associated .prj files.

Don Murray                               UCAR Unidata Program
dmurray@xxxxxxxxxxxxxxxx                        P.O. Box 3000
(303) 497-8628                              Boulder, CO 80307

To unsubscribe netcdf-java, visit:

  • 2006 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: