2

I am trying to generate a GeoTIFF from a grib2 section of the GFS weather model.

After downloading the area needed I select the band that I want to make the GeoTIFF with this command

gdal_translate -of GTIFF -B 42 GFS_Global_0p25deg_20210108_F024.grib2 /var/www/html/data/gfs_pcpn1.tif

The TIFF is generated but longitude coordinates are in positive number for western longitudes for example if checking it on QGIS the points are like 289.5,14.5 instead of -70.5,14.5. I need to overlay this on a map using lon,lat.

Is there a way to set the correct coordinates in the gdal_traslate process? This is what is shown of the generated TIFF in gdalinfo command.

This coordinates system information seems so confusing.

Size is 233, 133
Coordinate System is:
GEOGCS["Coordinate System imported from GRIB file",
    DATUM["unknown",
        SPHEROID["Sphere",6371229,0]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433]]
Origin = (241.875000000000000,33.125000000000000)
Pixel Size = (0.250000000000000,-0.250000000000000)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (     241.875,      33.125) (241d52'30.00"E, 33d 7'30.00"N)
Lower Left  (     241.875,      -0.125) (241d52'30.00"E,  0d 7'30.00"S)
Upper Right (     300.125,      33.125) (300d 7'30.00"E, 33d 7'30.00"N)
Lower Right (     300.125,      -0.125) (300d 7'30.00"E,  0d 7'30.00"S)
Center      (     271.000,      16.500) (271d 0' 0.00"E, 16d30' 0.00"N)
Band 1 Block=233x4 Type=Float64, ColorInterp=Gray
  Description = 0[-] SFC="Ground or water surface"
  Minimum=0.000, Maximum=127.312, Mean=3.777, StdDev=7.540
  Metadata:
    GRIB_COMMENT=24 hr Total precipitation [kg/(m^2)]
    GRIB_ELEMENT=APCP24
    GRIB_FORECAST_SECONDS=0 sec
    GRIB_PDS_PDTN=8
    GRIB_PDS_TEMPLATE_NUMBERS=1 8 2 0 96 0 0 0 1 0 0 0 0 1 0 0 0 0 0 255 0 0 0 0 0 7 229 1 9 0 0 0 1 0 0 0 0 1 2 1 0 0 0 24 255 0 0 0 0
    GRIB_REF_TIME=1610064000 sec UTC
    GRIB_SHORT_NAME=0-SFC
    GRIB_UNIT=[kg/(m^2)]
    GRIB_VALID_TIME=1610150400 sec UTC
    STATISTICS_MAXIMUM=127.3125
    STATISTICS_MEAN=3.7773161444383
    STATISTICS_MINIMUM=0
    STATISTICS_STDDEV=7.5399789437028
5
  • 1
    GDAL seems to find rather special coordinate system, a non-flattened sphere DATUM["unknown", SPHEROID["Sphere",6371229,0]],. You can try to force other extents by giving upper left - lower right coordinates with -a_ullr.
    – user30184
    Jan 12, 2021 at 8:12
  • The coordinates should be treated as belonging to the wgs84 ellipsoid. They enter the geographic coordinates of the stations into the spherical model without performing any transformation. The coordinate system can be overwritten, but I don't know if that solves the extension problem. Reprojecting may be the solution. Jan 12, 2021 at 10:45
  • 1
    You just need to shift all Y values by -360.
    – Vince
    Jan 12, 2021 at 11:54
  • Vince. I did that with rasterio in s post processing routine and works as expected but is there a way to do it with another GDAL command?
    – neavilag
    Jan 12, 2021 at 14:14
  • @user30184 thanks, actually with that parameter I was able to shift the values taking upper left lower right coords. -a_ullr -118.125 33.125 -59.875 -0.125
    – neavilag
    Jan 14, 2021 at 5:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.