[gdal-dev] gdal_translate from .nc --> .tif --- issue with coordinates

Andrew C Aitchison andrew at aitchison.me.uk
Fri Jul 16 08:10:30 PDT 2021


On Thu, 15 Jul 2021, Hill, David Foster wrote:

> Hello. I asked this question a few weeks ago, but I think my
> question was not complete enough, and I also think I did not attach
> the right files. So, I would like to try again, if that is ok.

I note that your earlier message said:
> The version is: GDAL 1.11.4, released 2016/01/25

I can reproduce your results with one of your files, with GDAL v1.11.5
but not with v1.9.2, v2.4.4 or 3.3.1.

Given that v1.anything is ancient, I suggest that you move to GDAL version 3.

> I have a .nc file. When I do:
>
>>> ncdump -c <file.nc>
>
> I can inspect the coordinates in the x and y directions. When I do
> this, it shows the x vector correctly as: 487200,
> 487300, 625300. And it shows the y vector correctly as 4690100,
> 4690200, 4937600. My file is in projected (EPSG:32612) coords.
>
> Next, I use gdal_translate to change .tif. I do this as:
>
> gdal_translate -of GTiff <file.nc> <file.tif>
>
> This is my question —> after converting to tif, I can look at the header info with gdalinfo. When I do this, I see:
>
> ****
> Corner Coordinates:
> Upper Left  (  486790.000, 4937650.000)
> Lower Left  (  486790.000, 4690050.000)
> Upper Right (  624990.000, 4937650.000)
> Lower Right (  624990.000, 4690050.000)
> Center      (  555890.000, 4813850.000)
> ****
>
> The y coord of lower left is 4690050 compare that to the info above
> about the .nc file. I think this is ok. It is 50m
> different. Presumably, ncdump is reporting on the coords of grid
> centers and gdalinfo is reporting on boundaries (1/2 a grid cell
> difference), so it is 50 m less. Fine. BUT, look at the x coord of
> the lower left grid cell. It is 486790, compared to 487200 in the
> netcdf file. In other words, the x coord of the tif file is like 410
> m less than the netcdf file. I am very confused about the difference
> in the x coordinate vector between the .nc and the .tif files.
>
> Is there a different way that I should be using gdal_translate to
> avoid this 400 m ‘offset’? I can certainly override the limits with
> -a_ullr, and that works fine, and gives me the expected coordinate
> values and 100 m grid resolution, etc. However, that does not seem
> like the most elegant solution.
>
> Dave.
>
> files here: https://drive.google.com/drive/folders/1CclJGBj_L_Z-9hq_Xkse0ARKDdnNvKZJ?usp=sharing
> <https://drive.google.com/drive/folders/1CclJGBj_L_Z-9hq_Xkse0ARKDdnNvKZJ?usp=sharing>


-- 
Andrew C. Aitchison					Kendal, UK
 			andrew at aitchison.me.uk


More information about the gdal-dev mailing list