[GRASS-user] GRIB2 r.in.gdal problem

I’m trying to import some GRIB2 data into GRASS (6.4.3 on a Mac) and am having a problem with the range of the latitude coordinates. I’m working with the following file:

  http://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs.2014021112/gfs.t12z.master.grbf72.10m.uv.grib2

I used gdal_translate to create a GeoTiff file, but when I try to import it into a lat/lon location I get the following:

GRASS 6.4.3 (GFS_from_grib):~ > r.in.gdal input=gfs.t12z.master.grbf72.10m.uv.tif output=gfs
WARNING: Datum <unknown> not recognised by GRASS and no parameters found
Projection of input dataset and current location appear to match
WARNING: G_set_window(): Illegal latitude for North

Here is the output from gdalinfo:

lees-mbp:GFS Lee$ gdalinfo gfs.t12z.master.grbf72.10m.uv.tif
Driver: GTiff/GeoTIFF
Files: gfs.t12z.master.grbf72.10m.uv.tif
       gfs.t12z.master.grbf72.10m.uv.tif.aux.xml
Size is 720, 361
Coordinate System is:
GEOGCS["Coordinate System imported from GRIB file",
    DATUM["unknown",
        SPHEROID["Sphere",6371229,0]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433]]
Origin = (-0.250000000000000,90.250000000000000)
Pixel Size = (0.500000000000000,-0.500000000000000)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left ( -0.2500000, 90.2500000) ( 0d15' 0.00"W, 90d15' 0.00"N)
Lower Left ( -0.2500000, -90.2500000) ( 0d15' 0.00"W, 90d15' 0.00"S)
Upper Right ( 359.750, 90.250) (359d45' 0.00"E, 90d15' 0.00"N)
Lower Right ( 359.750, -90.250) (359d45' 0.00"E, 90d15' 0.00"S)
Center ( 179.7500000, 0.0000000) (179d45' 0.00"E, 0d 0' 0.01"N)
Band 1 Block=720x1 Type=Float64, ColorInterp=Gray
  Description = 10[m] HTGL="Specified height level above ground"
  Metadata:
    GRIB_COMMENT=u-component of wind [m/s]
    GRIB_ELEMENT=UGRD
    GRIB_FORECAST_SECONDS=259200 sec
    GRIB_PDS_PDTN=0
    GRIB_PDS_TEMPLATE_NUMBERS=2 2 2 0 96 0 0 0 1 0 0 0 72 103 0 0 0 0 10 255 0 0 0 0 0
    GRIB_REF_TIME=1392120000 sec UTC
    GRIB_SHORT_NAME=10-HTGL
    GRIB_UNIT=[m/s]
    GRIB_VALID_TIME=1392379200 sec UTC
Band 2 Block=720x1 Type=Float64, ColorInterp=Undefined
  Description = 10[m] HTGL="Specified height level above ground"
  Metadata:
    GRIB_COMMENT=v-component of wind [m/s]
    GRIB_ELEMENT=VGRD
    GRIB_FORECAST_SECONDS=259200 sec
    GRIB_REF_TIME=1392120000 sec UTC
    GRIB_SHORT_NAME=10-HTGL
    GRIB_UNIT=[m/s]
    GRIB_VALID_TIME=1392379200 sec UTC

So it’s showing the north and south bounds of 90.25 N and -90.25 S. I’m almost positive that this would be the values of the edges of the cells and that the cells are centered at 90 N and 90 S.

Is there a way to import this data?

Thanks,
Lee

(sorry for top posting, no time to deal with yahoo mail today)

Hi,

note for GRIB you need gdal 1.10 or newer, there were
edge coordinate bugs in earlier versions.

---> see: http://grasswiki.osgeo.org/wiki/GRIB

note grass uses the cell-center for data value convention,
not the data values at grid line confluences (nodes) convention for raster arrays.

and so in grass the region's e,w,s,n values are at the outer edge of the raster cells, while gridline-centered arrays* would give coords overhanging the edges of the region by half a cell.

sometimes when loading in gridline-centered data you need to crop away the data row at 90N,S and one of the two at 0,360 or +-180 longitude. See the MODIS page in the wiki perhaps.
the way there is to use 'r.in.gdal -l' to force it to fit into 90N,S, then carefully use g.region + r.mapcalc to crop away the two rows, then use r.region to fix the map bounds back to where they should.

resolution ends up with bounds at e.g. 25,75m with a cell size of 50m, you have to be careful that d.zoom or 'g.region -a' doesn't realign the bounds to 0,50,100m instead of 25,75 (so silently shifted by 1/2 a cell).

* (usually can spot them as they have like 501x1001 cells not 500x1000)

http://grasswiki.osgeo.org/wiki/GRASS_raster_semantics#Cell_Locations

http://grasswiki.osgeo.org/wiki/GRASS_FAQ#Errors

but the first thing to verify for the GRIB format is that your gdal version is 1.10 or newer.

regards,

Hamish

On Wednesday, February 12, 2014 6:21 PM, Lee Eddington <lee.w.eddington@gmail.com> wrote:

I’m trying to import some GRIB2 data into GRASS (6.4.3 on a Mac) and am having a problem with the range of the latitude coordinates. I’m working with the following file:

http://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs.2014021112/gfs.t12z.master.grbf72.10m.uv.grib2

I used gdal_translate to create a GeoTiff file, but when I try to import it into a lat/lon location I get the following:

GRASS 6.4.3 (GFS_from_grib):~ > r.in.gdal input=gfs.t12z.master.grbf72.10m.uv.tif output=gfs
WARNING: Datum <unknown> not recognised by GRASS and no parameters found
Projection of input dataset and current location appear to match
WARNING: G_set_window(): Illegal latitude for North

Here is the output from gdalinfo:

lees-mbp:GFS Lee$ gdalinfo gfs.t12z.master.grbf72.10m.uv.tif
Driver: GTiff/GeoTIFF
Files: gfs.t12z.master.grbf72.10m.uv.tif
gfs.t12z.master.grbf72.10m.uv.tif.aux.xml
Size is 720, 361
Coordinate System

is:

GEOGCS["Coordinate System imported from GRIB file",
DATUM["unknown",
SPHEROID["Sphere",6371229,0]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433]]
Origin = (-0.250000000000000,90.250000000000000)
Pixel Size = (0.500000000000000,-0.500000000000000)
Metadata:
AREA_OR_POINT=Area
Image Structure Metadata:
INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left ( -0.2500000, 90.2500000) ( 0d15' 0.00"W, 90d15' 0.00"N)
Lower Left ( -0.2500000, -90.2500000) ( 0d15' 0.00"W, 90d15' 0.00"S)
Upper Right ( 359.750, 90.250) (359d45' 0.00"E, 90d15' 0.00"N)
Lower Right ( 359.750, -90.250) (359d45' 0.00"E, 90d15' 0.00"S)
Center ( 179.7500000, 0.0000000) (179d45' 0.00"E, 0d 0' 0.01"N)
Band 1

Block=720x1 Type=Float64, ColorInterp=Gray

Description = 10[m] HTGL="Specified height level above ground"
Metadata:
GRIB_COMMENT=u-component of wind [m/s]
GRIB_ELEMENT=UGRD
GRIB_FORECAST_SECONDS=259200 sec
GRIB_PDS_PDTN=0
GRIB_PDS_TEMPLATE_NUMBERS=2 2 2 0 96 0 0 0 1 0 0 0 72 103 0 0 0 0 10 255 0 0 0 0 0
GRIB_REF_TIME=1392120000 sec UTC
GRIB_SHORT_NAME=10-HTGL
GRIB_UNIT=[m/s]
GRIB_VALID_TIME=1392379200 sec UTC
Band 2 Block=720x1 Type=Float64, ColorInterp=Undefined
Description = 10[m] HTGL="Specified height level above ground"
Metadata:
GRIB_COMMENT=v-component of wind [m/s]
GRIB_ELEMENT=VGRD
GRIB_FORECAST_SECONDS=259200 sec
GRIB_REF_TIME=1392120000 sec UTC

GRIB_SHORT_NAME=10-HTGL

GRIB\_UNIT=\[m/s\]
GRIB\_VALID\_TIME=1392379200 sec UTC

So it’s showing the north and south bounds of 90.25 N and -90.25 S. I’m almost positive that this would be the values of the edges of the cells and that the cells are centered at 90 N and 90 S.

Is there a way to import this data?

Thanks,
Lee

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

I upgraded gdal to 1.10 and used r.in.gdal -l and was able to read the file and display it with no problems.

Thanks,
Lee

On Feb 13, 2014, at 5:35 PM, Hamish <hamish_b@yahoo.com> wrote:

(sorry for top posting, no time to deal with yahoo mail today)

Hi,

note for GRIB you need gdal 1.10 or newer, there were
edge coordinate bugs in earlier versions.

---> see: http://grasswiki.osgeo.org/wiki/GRIB

note grass uses the cell-center for data value convention,
not the data values at grid line confluences (nodes) convention for raster arrays.

and so in grass the region's e,w,s,n values are at the outer edge of the raster cells, while gridline-centered arrays* would give coords overhanging the edges of the region by half a cell.

sometimes when loading in gridline-centered data you need to crop away the data row at 90N,S and one of the two at 0,360 or +-180 longitude. See the MODIS page in the wiki perhaps.
the way there is to use 'r.in.gdal -l' to force it to fit into 90N,S, then carefully use g.region + r.mapcalc to crop away the two rows, then use r.region to fix the map bounds back to where they should.

resolution ends up with bounds at e.g. 25,75m with a cell size of 50m, you have to be careful that d.zoom or 'g.region -a' doesn't realign the bounds to 0,50,100m instead of 25,75 (so silently shifted by 1/2 a cell).

* (usually can spot them as they have like 501x1001 cells not 500x1000)

http://grasswiki.osgeo.org/wiki/GRASS_raster_semantics#Cell_Locations

http://grasswiki.osgeo.org/wiki/GRASS_FAQ#Errors

but the first thing to verify for the GRIB format is that your gdal version is 1.10 or newer.

regards,

Hamish

On Wednesday, February 12, 2014 6:21 PM, Lee Eddington <lee.w.eddington@gmail.com> wrote:

I’m trying to import some GRIB2 data into GRASS (6.4.3 on a Mac) and am having a problem with the range of the latitude coordinates. I’m working with the following file:

    http://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs.2014021112/gfs.t12z.master.grbf72.10m.uv.grib2

I used gdal_translate to create a GeoTiff file, but when I try to import it into a lat/lon location I get the following:

GRASS 6.4.3 (GFS_from_grib):~ > r.in.gdal input=gfs.t12z.master.grbf72.10m.uv.tif output=gfs
WARNING: Datum <unknown> not recognised by GRASS and no parameters found
Projection of input dataset and current location appear to match
WARNING: G_set_window(): Illegal latitude for North

Here is the output from gdalinfo:

lees-mbp:GFS Lee$ gdalinfo gfs.t12z.master.grbf72.10m.uv.tif
Driver: GTiff/GeoTIFF
Files: gfs.t12z.master.grbf72.10m.uv.tif
       gfs.t12z.master.grbf72.10m.uv.tif.aux.xml
Size is 720, 361
Coordinate System

is:

GEOGCS["Coordinate System imported from GRIB file",
    DATUM["unknown",
        SPHEROID["Sphere",6371229,0]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433]]
Origin = (-0.250000000000000,90.250000000000000)
Pixel Size = (0.500000000000000,-0.500000000000000)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left ( -0.2500000, 90.2500000) ( 0d15' 0.00"W, 90d15' 0.00"N)
Lower Left ( -0.2500000, -90.2500000) ( 0d15' 0.00"W, 90d15' 0.00"S)
Upper Right ( 359.750, 90.250) (359d45' 0.00"E, 90d15' 0.00"N)
Lower Right ( 359.750, -90.250) (359d45' 0.00"E, 90d15' 0.00"S)
Center ( 179.7500000, 0.0000000) (179d45' 0.00"E, 0d 0' 0.01"N)
Band 1

Block=720x1 Type=Float64, ColorInterp=Gray

  Description = 10[m] HTGL="Specified height level above ground"
  Metadata:
    GRIB_COMMENT=u-component of wind [m/s]
    GRIB_ELEMENT=UGRD
    GRIB_FORECAST_SECONDS=259200 sec
    GRIB_PDS_PDTN=0
    GRIB_PDS_TEMPLATE_NUMBERS=2 2 2 0 96 0 0 0 1 0 0 0 72 103 0 0 0 0 10 255 0 0 0 0 0
    GRIB_REF_TIME=1392120000 sec UTC
    GRIB_SHORT_NAME=10-HTGL
    GRIB_UNIT=[m/s]
    GRIB_VALID_TIME=1392379200 sec UTC
Band 2 Block=720x1 Type=Float64, ColorInterp=Undefined
  Description = 10[m] HTGL="Specified height level above ground"
  Metadata:
    GRIB_COMMENT=v-component of wind [m/s]
    GRIB_ELEMENT=VGRD
    GRIB_FORECAST_SECONDS=259200 sec
    GRIB_REF_TIME=1392120000 sec UTC
   

GRIB_SHORT_NAME=10-HTGL

    GRIB_UNIT=[m/s]
    GRIB_VALID_TIME=1392379200 sec UTC

So it’s showing the north and south bounds of 90.25 N and -90.25 S. I’m almost positive that this would be the values of the edges of the cells and that the cells are centered at 90 N and 90 S.

Is there a way to import this data?

Thanks,
Lee

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Lee wrote:

I upgraded gdal to 1.10 and used r.in.gdal -l and was able to read the
file and display it with no problems.

Great. The edge row cropping and fixing with r.region can be a little
tricky, as can managing a region aligned to the 1/2 cell offset raster,
not one rounded to the raster resolution, but as long as you're careful
everything should end up aligning ok. Check against a coastline like
Natural Earth's.

regards,
Hamish