Hi Jukka,

If GDAL shuffled around the pixels in that file, you wouldn't be able to notice 
it by comparing the GRIB and the TIFF, because both would be shuffled.

My suggestion was to convert the GRIB to a NC or even CSV using xarray, then 
comparing the GDAL output against that.

Laurentiu

On Thu, Feb 1, 2024, at 13:18, Rahkonen Jukka via gdal-dev wrote:
> Hi,
>  
> I used the gdal_compare script https://gdal.org/programs/gdalcompare.html
> 
> gdalcompare  st4_pr.2017092016.01h st4_pr.2017092016.01h.tif
> and it reports three differences:
>  • Files differ at the binary level (normal, GRIB and tif are not the same)
>  • Difference in SRS (but they are alike, * IsSame() reports them as 
> equivalent.)
>  • Difference in Dataset metadata key count ( ['AREA_OR_POINT'] added)
> So if I read the report right the pixels in the files are identical. All I 
> can conclude is that gdal_compare and your R script are doing something in 
> different ways.
>  
> -Jukka Rahkonen-
>  
> *Lähettäjä:* gdal-dev <gdal-dev-boun...@lists.osgeo.org> *Puolesta *Furuya, 
> Takahiro via gdal-dev
> *Lähetetty:* torstai 1. helmikuuta 2024 1.53
> *Vastaanottaja:* gdal-dev@lists.osgeo.org
> *Aihe:* [gdal-dev] gdal_translate shifted values
> 
>  
> Hi gdal-dev, I am Takahiro, a student who is using gdal_translate.
> I have an issue with gdal_translate and would like to ask a question.
> I used gdal_translate to transform a NCEP GRIB file (downloadable from 
> https://data.eol.ucar.edu/cgi-bin/codiac/fgr_form/id=21.093, or attached to 
> this email) to GeoTiff, and compare those 2 data formats. The command I used 
> is
> >gdal_translate -of GTiff st4_pr.2017092016.01h st4_pr.2017092016.01h.tif
>  
> (The GRIB file I used was st4_pr.2017092016.01h, which can be downloaded from 
> the above link by specifying “Begin Date/Time” to “20170920”/“15:00:00”  and 
> “End Date/Time” to “20170920”/“15:59:59”.)
>  
> Then I read the 2 data files in R and checked if the original value at a 
> certain grid cell in the GRIB file remained at the same grid cell in the 
> GeoTiff file, but the value was shifted by 6 rows (the value I checked was 
> 9.75 [mm/hour] that was stored in index [100,86] in the original GRIB file, 
> but it was shifted to [106,86] in the GeoTiff file).
>  
> You can see the Python script used for reading the original GRIB file here: 
> https://bpa.st/ZNOSI
> The R script used for checking the tif-translated data: https://bpa.st/WZLSY
>  
> The version of gdal_translate I used is 3.0.2.
> Is this a known issue of gdal_translate? Or is this issue not supposed to 
> happen (is this the mistake of my side?)?
>  
> Best regards,
> Takahiro
>  
>  
>  
> _______________________________________________
> gdal-dev mailing list
> gdal-dev@lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
> 
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to