[Gdal-dev] NetCDF.. the world turned upside-down

Matthew Perry perrygeo at gmail.com
Mon Apr 10 13:17:13 EDT 2006


Hey folks,

 I ran into an issue using GDAL to access a NetCDF file;  The lower
lattitude of the dataset is further north than the upper lattitude!

$ gdalinfo sstnc.nc
...
Corner Coordinates:
Upper Left  ( -79.6223913,  31.3360993) ( 79d37'20.61"W, 31d20'9.96"N)
Lower Left  ( -79.6223913,  36.9168329) ( 79d37'20.61"W, 36d55'0.60"N)
Upper Right ( -72.8531371,  31.3360993) ( 72d51'11.29"W, 31d20'9.96"N)
Lower Right ( -72.8531371,  36.9168329) ( 72d51'11.29"W, 36d55'0.60"N)
Center      ( -76.2377642,  34.1264661) ( 76d14'15.95"W, 34d 7'35.28"N)
...

gdal_translating the image yields an upside-down image as a result.  I
can get around it by adding ground control points and warping the
image:

$ gdal_translate \
 -gcp 0   0   -79.6223913 31.3360993 \
 -gcp 512 511 -72.8531371 36.9168329 \
 -gcp 0   511 -79.6223913 36.9168329 \
 -gcp 512 0   -72.8531371 31.3360993 \
  sstnc.nc sstnc_gcp.tif
$ gdalwarp sstnc_gcp.tif sstnc_good.tif

While this seems to work OK, the image is now 559x461 whereas the
original image is 513x512 and the pixel size has been altered
accordingly which causes alot of unneccesary resampling.

Is there a way to get gdal utilities to recognize the upside-down
nature of the image and "flip" it accordingly without
warping/resampling it?? Or does this call for using the GDAL API?

--
Matt Perry
perrygeo at gmail.com
http://www.perrygeo.net




More information about the Gdal-dev mailing list