[GRASS-user] Problem importing netCDF

Hamish hamish_b at yahoo.com
Sat Jun 5 06:17:59 EDT 2010


Hanlie wrote:
> I'm using Win XP and GRASS 6.4RC6 to import a TRMM netCDF
> file using the command:
> -----
> r.in.gdal -o input =c:/data/3B42.000202.0.6.nc output=test
> band=precipitation
> -----
> 
> and am getting the error:
> -----
> G_set_window(): Illegal latitude for North
> -----
> 
> gdalinfo for the file outputs:
> -----
> Driver: netCDF/Network Common Data Format
> Files: C:\data\3B42.000202.0.6.nc
>    
>    C:\data\3B42.000202.0.6.nc.aux.xml
> Size is 512, 512
> Coordinate System is `'
> Metadata:
>   NC_GLOBAL#Conventions=CF-1.0
> Subdatasets:
>  
> SUBDATASET_1_NAME=NETCDF:"C:\data\3B42.000202.0.6.nc":precipitation
>   SUBDATASET_1_DESC=[400x1440] precipitation (32-bit
> floating-point)
>  
> SUBDATASET_2_NAME=NETCDF:"C:\data\3B42.000202.0.6.nc":relativeError
>   SUBDATASET_2_DESC=[400x1440] relativeError (32-bit
> floating-point)
> Corner Coordinates:
> Upper Left  (    0.0,    0.0)
> Lower Left  (    0.0,  512.0)
> Upper Right (  512.0,    0.0)
> Lower Right (  512.0,  512.0)
> Center      (  256.0,  256.0)
> -----


in a lat-lon location you can no exceed 90 degrees North or 90 degrees
South.

Your data file has a coordinate system unknown to GDAL (empty) so it
tries to import it with 1 pixel = 1 degree, and gets upset with a coord
of 512 degrees north.

Newer versions of GRASS (6.5+?) have a flag in r.in.gdal to force the map
to fit into geographic space, then you can use r.region to fix the bounds
manually. If you look on the GRASS wiki's "MODIS" page I think you can
find some examples of how to fix this with gdal_translate. The general
idea is to use gdal_translate to extract a GeoTiff from the netCDF file
and set the coord system and geographic bounds, then import that GeoTiff
into GRASS.


> In Panoply (http://www.giss.nasa.gov/tools/panoply/), the
> information
> for the file displays as:
> -----
> netcdf file:/C:/data/3B42.000202.0.6.nc {
>  dimensions:
>    lat = 400;
>    lon = 1440;
>  variables:
>    float precipitation(lat=400, lon=1440);
>      :long_name = "precipitation";
>      :units = "mm hr-1";
>      :_FillValue = -9999.9f; // float
>    float relativeError(lat=400, lon=1440);
>      :long_name = "relativeError";
>      :units = "mm hr-1";
>      :_FillValue = -9999.9f; // float
>    float lat(lat=400);
>      :standard_name = "latitude";
>      :units = "degrees_north";
>      :long_name = "latitude";
>      :_CoordinateAxisType = "Lat";
>    float lon(lon=1440);
>      :standard_name = "longitude";
>      :units = "degrees_east";
>      :long_name = "longitude";
>      :_CoordinateAxisType = "Lon";
> 
>  :Conventions = "CF-1.0";
> }
> -----
> 
> In the Panoply array display, the coordinates range from
> 49.875° to
> -49.875° (lattitude) and  -179.875° to +179.875°
> longitude. These are
> coordinates for the centres of 0.25° grid cells.
> 
> I have set my region according to the documentation for the
> dataset to:
> -----
> projection: 3 (Latitude-Longitude)
> zone:       0
> datum:      wgs84
> ellipsoid:  wgs84
> north:      50N
> south:      50S
> west:       180W
> east:       180E
> nsres:      0:15
> ewres:      0:15
> rows:       400
> cols:       1440
> cells:      576000
> -----



good luck,
Hamish


      


More information about the grass-user mailing list