[GRASS-dev] [GRASS GIS] #1599: netcdf input upside down raster

#1599: netcdf input upside down raster
---------------------------------------------+------------------------------
Reporter: michpaulatto | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone:
Component: Raster | Version: 6.4.0
Keywords: input netcdf upside down raster | Platform: Linux
      Cpu: x86-64 |
---------------------------------------------+------------------------------
What I'm trying to do: I'm importing netcdf elevation and/or gravity grids
(.grd) into grass.

The problem: imported raster is sometimes upside down

Example: two netcdf grid files generated with GMT's grdsample. dem.grd and
grav.grd, see below output of grdinfo:

% grdinfo dem.grd [[BR]]
  dem.grd: Title: dem.grd[[BR]]
  dem.grd: Command: grdsample -R173/193/-39/-15 -I0.02 Complete_merged.grd
-Gdem.grd[[BR]]
  dem.grd: Remark:[[BR]]
  dem.grd: Gridline node registration used[[BR]]
  dem.grd: Grid file format: nf (# 18) GMT netCDF format (float) (COARDS-
compliant) [DEFAULT] [[BR]]
  dem.grd: x_min: 173 x_max: 193 x_inc: 0.02 name: longitude [degrees_east]
nx: 1001[[BR]]
  dem.grd: y_min: -39 y_max: -15 y_inc: 0.02 name: latitude [degrees_north]
ny: 1201[[BR]]
  dem.grd: z_min: -10804.1416016 z_max: 714.619628906 name: z[[BR]]
  dem.grd: scale_factor: 1 add_offset: 0[[BR]]

% grdinfo grav.grd [[BR]]
  grav.grd: Title: grav.grd[[BR]]
  grav.grd: Command: grdsample -R173/193/-39/-15 -I0.1 temp
-Ggrav.grd[[BR]]
  grav.grd: Remark: [[BR]]
  grav.grd: Gridline node registration used[[BR]]
  grav.grd: Grid file format: nf (# 18) GMT netCDF format (float) (COARDS-
compliant) [DEFAULT] [[BR]]
  grav.grd: x_min: 173 x_max: 193 x_inc: 0.1 name: x nx: 201[[BR]]
  grav.grd: y_min: -39 y_max: -15 y_inc: 0.1 name: y ny: 241[[BR]]
  grav.grd: z_min: -270.356201172 z_max: 203.824752808 name: z[[BR]]
  grav.grd: scale_factor: 1 add_offset: 0[[BR]]

When I import these two files into grass (from the GUI) dem.grd results in
a correct raster while grav.grd results in an upside down raster. This
happens with other grd files I've tried, but this example is quite
interesting since the two grd files cover the same area, have the same
dimensions and have been generated in exactly the same way. They have
different grid spacing. Any clues?

Thanks. Michele.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1599&gt;
GRASS GIS <http://grass.osgeo.org>

#1599: netcdf input upside down raster
---------------------------------------------+------------------------------
Reporter: michpaulatto | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone:
Component: Raster | Version: 6.4.0
Keywords: input netcdf upside down raster | Platform: Linux
      Cpu: x86-64 |
---------------------------------------------+------------------------------

Comment(by neteler):

Please report which GDAL version you use. There are a few issues in the
related
netCDF driver (more links therein to other tickets):

http://trac.osgeo.org/gdal/ticket/2846

http://trac.osgeo.org/gdal/ticket/1926

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1599#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#1599: netcdf input upside down raster
---------------------------------------------+------------------------------
Reporter: michpaulatto | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone:
Component: Raster | Version: 6.4.0
Keywords: input netcdf upside down raster | Platform: Linux
      Cpu: x86-64 |
---------------------------------------------+------------------------------

Comment(by cmbarton):

I've been reading a number of highly variable NetCDF files in the last
month while I'm here at NCAR, one of the big users of NetCDF.

I've found that some software reads NetCDF files upside down (including
ImageJ, the current stable version of MultiSpec, and ArcGIS). We are
speculating that this is because NetCDF raster files are meant to be read
from the bottom left, rather than from the top left like normal image
files--but like georeferenced raster maps.

However, r.in.gdal seems to consistently read these files correctly in all
cases--once the proper input string has been determined. New dev versions
of MultiSpec also are reading NetCDF files correctly now. (I added
information to the GRASS Wiki for r.in.gdal to describe how to read *.nc
files into GRASS.) These are working fine in GDAL 1.8 and 1.9

That said, the other tickets are from 3-4 years back and both refer to GMT
files, as does this ticket. So I wonder if there is something that happens
when GMT makes NetCDF or when they pass through GMT that throws GDAL off ?

Michael

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1599#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>