gdal icon indicating copy to clipboard operation
gdal copied to clipboard

"gdalwarp -t_srs +proj=lee_os" add NaNs rows in projected file

Open joa-quim opened this issue 3 months ago • 8 comments

What is the bug?

When using gdalwarp to project a grid with the Lee projection extraneous rows of NaNs (an other values) show up in the result in position that seem to depend on the input grid's resolution.

The example shown uses GMT to create the input (netCDF) grid.

Steps to reproduce the issue

# GMT command that reads part of a global grid with limits -Rlon_min/lon_max/lat_min/lat_max
grdcut @earth_relief_20m_p -R70.0/300.0/-90.0/85.0 -Glixo.grd

# GDAL seams to not like nc files created by GMT so I must convert it with `gdal_translate`
gdal_translate lixo.grd lixo.nc

gdalwarp lixo.nc lixo1.tiff -t_srs +proj=lee_os -s_srs +proj=lonlat

Versions and provenance

Windows 11

gdalinfo --version GDAL 3.12.0dev-7b06d23399-dirty, released 2025/07/11

Additional context

Image

joa-quim avatar Aug 27 '25 18:08 joa-quim

After running the first command I have now file lixo.grd, but is the command for creating lixo.nc missing?

jratike80 avatar Aug 27 '25 19:08 jratike80

Sorry, I copied a command twice. Fixed now (edited). The command is

gdal_translate lixo.grd lixo.nc

and note that if we select nc as output the created file has 0 bytes. That is lixo1.nc bellow is empty

gdalwarp lixo.nc lixo1.nc -t_srs +proj=lee_os -s_srs +proj=lonlat

joa-quim avatar Aug 27 '25 19:08 joa-quim

Is the conversion into nc necessary? I can see similar line by warping the .grd directly. I trier couple of warping options but they do not remove the line.

gdalwarp lixo.grd lixo4.tiff -t_srs +proj=lee_os -s_srs +proj=lonlat -wo sample_steps=all -wo source_extra=10

jratike80 avatar Aug 27 '25 19:08 jratike80

You are right, it is not. I guess I had to do it before adding the -s_srs +proj=lonlat. BTW the grd is also netCDF but the grdcut command is not setting enough metadata so that GDAL recognize it as a geographical grid.

tried couple of warping options but they do not remove the line.

me too, and I can get worse cases when using other grid resolutions/extents.

joa-quim avatar Aug 27 '25 20:08 joa-quim

I have no more questions and asking questions is all I can do, I know nothing about netCDF or the lee projection.

jratike80 avatar Aug 27 '25 20:08 jratike80

The issue has nothing to do with netCDF. It showed up for me in the Julia wrapper where input is already an array in memory. It's all about the Lee projection, a nice one for representing the Pacific Ocean.

(Thanks for looking)

joa-quim avatar Aug 27 '25 20:08 joa-quim

I don't have GMT at hand. Can you attach a (as small as possible) GeoTIFF/netCDF that can reproduce the issue?

rouault avatar Aug 29 '25 17:08 rouault

This shows it:

gdalwarp lixo.grd lixo.tiff -t_srs +proj=lee_os -s_srs +proj=lonlat

lixo.grd.zip

joa-quim avatar Aug 29 '25 17:08 joa-quim