[Gdal-dev] gdal_translate for netCDF to AAIGrid
mwtoews at sfu.ca
Tue Oct 24 14:43:12 EDT 2006
'gdal_translate' on a netCDF file to an AAIGrid has odd behaviour using
GDAL 188.8.131.52 under Cygwin. My conversion:
$ gdal_translate -of AAIGrid -sds test.nc test.asc
$ mv test.asc1 test.asc
No errors were generated during the conversion.
The header of the AAIGrid output is:
However, these headers should read:
The dx/dy in the output of the file was incorrectly calculated as:
which is both why they are different (dx != dy because ncols != nrows),
and why they are not correct, since they are multiplied by the ratio of
base0/base1 representations of their dimension lengths.
My netCDF file (attached) should has a cellsize of exactly 100, since my
data are spaced every 100 m in the x- and y-dims. This netCDF file was
produced using a custom python script, which uses Scientific.IO.NetCDF
for python 2.3. The file was later averaged, using 'ncra', which is part
of NCO (command viewed in 'history' global attribute). My netCDF file is
not perfect; I've recently discovered that my 'ydim' is 5463700,
5463600, ..., 5441300; or it is in reverse order (dy = -100). For netCDF
files, this should not matter (although I'll admit that it is a bit
sloppy); I've been able to use the file as normal with 'ncview' and NCO.
(As a caution, I have also seen some netCDF files which order their
latitudes from North to South, which is also in reverse order; I'm not
sure if this is tested, and corrected in GDAL, but I would highly advise
it for netCDF files).
I also get strange behaviour with 'gdalinfo'. Try:
$ gdalinfo test.nc
$ gdalinfo test.asc # using the correct header
Both the 'Size' and the 'Corner Coordinates' are pretty strange for the
test.nc file, as it seems to think that it is 512x512.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 79980 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20061024/d9458190/test.nc
More information about the Gdal-dev