[gdal-dev] convert NETCDF to Geotiff upside down

Michael Sumner mdsumner at gmail.com
Wed Aug 9 14:37:36 PDT 2023


just a follow up, as far as I can tell the lon,lat arrays are actually
natively in global Mercator, so a four-number extent would suffice  but
these arrays have been materialized rather than preserve that compact
origin (it's very common sadly). You might feed that back to the providers
and/or other users of the data, shipping these lon,lat arrays is
unfortunate when simple georeferencing (extent, expressed as affine
transform and a crs) would do. There's more metadata than data in these
files ...

I've used many tricks to workaround bad formats like these, but now I'd
just say to shove it through the warper because that is now so fast and
reliable.

Cheers, MIke



On Thu, Aug 10, 2023 at 7:17 AM Michael Sumner <mdsumner at gmail.com> wrote:

> there is no georeferencing with this one, but as you say it has internal
> coordinates (which GDAL interprets as "geolocation arrays")
>
> so, run it through the warper i.e.
>
> gdalwarp NETCDF:GLOBCOMPLIR_nc.2023080819:data ofn.tif
>
> With that you can (and should) set your desired extent (-te), dimensions
> (-ts) [or resolution -tr], and crs (-t_crs) but GDAL will produce an output
> that works by heuristics if you specify none (or some) of those.
>
> I did the following just for fun to see if the non-downloading pathway
> would work it (not sure if the config is required or not, for testing
> purposes I set dimension to 1024,0 which means GDAL figures out a sensible
> aspect ratio - just remove -ts when you're happy with the result for full
> resolution. )
>
> gdalwarp --config AWS_NO_SIGN_REQUEST "YES"
> NETCDF:"/vsis3/noaa-gmgsi-pds/GMGSI_LW/2023/08/08/19/GLOBCOMPLIR_nc.2023080819":data
> -ts 1024 0 GLOBCOMPLIR_nc.2023080819_test.tif
>
> (some details might not work depending on your GDAL version)
>
> Cheers, Mike
>
> On Thu, Aug 10, 2023 at 6:30 AM Dori <izzybitsie at gmail.com> wrote:
>
>> Hi,
>> I tried to convert the NETCDF stored in
>> https://noaa-gmgsi-pds.s3.amazonaws.com/index.html#GMGSI_LW/202308/08/19/GLOBCOMPLIR_nc.2023080819
>>  to Geotiff format using following command:
>>
>> gdal_translate 0ol GTiff -a_srs EPSG:4326 -aullr -180 -72.7 179.9 -72.7
>> -co “COMPRESS=LZW” NETCDF:GLOBCOMPLIR_nc.2023080819:data ofn.tif
>>
>> ofn.tif is upside down.  North latitude points are in South and viceversa.
>>
>> How can I solve this upside down output?
>> What causes this?
>>
>> I did notice that the points in the NETCDF file are not equidistant  what
>> could be my issue.
>>
>> Thank you for any hint on how to go about getting the correct Geotiff
>> output
>>
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>
>
> --
> Michael Sumner
> Software and Database Engineer
> Australian Antarctic Division
> Hobart, Australia
> e-mail: mdsumner at gmail.com
>


-- 
Michael Sumner
Software and Database Engineer
Australian Antarctic Division
Hobart, Australia
e-mail: mdsumner at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20230810/bf06a609/attachment.htm>


More information about the gdal-dev mailing list