Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netcdf 6195 assume longlat #6910

Merged
merged 16 commits into from Dec 15, 2022
Merged

Conversation

mdsumner
Copy link
Contributor

@mdsumner mdsumner commented Dec 13, 2022

Implements the wish of #6195 to assume a regular grid NetCDF in a reasonable longitude/latitude range adopts the OGC:CRS84 crs, when all prior attempts to find one have failed.

  • when all other attempts have been tried, we check the bounds and give it longlat crs if within -180,360 -90,90
  • new config option GDAL_NETCDF_ASSUME_LONGLAT default NO, set to YES to apply the crs
  • new open option ASSUME_LONGLAT same as config option GDAL_NETCDF_ASSUME_LONGLAT

There is a python test on netcdf/trmm-nc2.nc that invokes the use of the setting (this file otherwise doesn't have a crs set).

What are related issues/pull requests?

#6195

Example

here on a remote file, provides a CRS OGC:CRS84 only if the config option is set

export GDAL_NETCDF_ASSUME_LONGLAT=YES
gdalinfo NETCDF:"/vsicurl/https://rsg.pml.ac.uk/thredds/fileServer/cci/v6.0-release/geographic/daily/chlor_a/2021/ESACCI-OC-L3S-CHLOR_A-MERGED-1D_DAILY_4km_GEO_PML_OCx-20210101-fv6.0.nc":chlor_a -nomd

examples to invoke option control and overrides

export GDAL_NETCDF_ASSUME_LONGLAT=NO
gdalinfo ../autotest/gdrivers/data/netcdf/trmm-nc2.nc -nomd
gdalinfo ../autotest/gdrivers/data/netcdf/trmm-nc2.nc -nomd -oo ASSUME_LONGLAT=YES

export GDAL_NETCDF_ASSUME_LONGLAT=YES
gdalinfo ../autotest/gdrivers/data/netcdf/trmm-nc2.nc -nomd
gdalinfo ../autotest/gdrivers/data/netcdf/trmm-nc2.nc -nomd -oo ASSUME_LONGLAT=NO

Note that this flollowing file doesn't benefit from the assumption, because its geotransform puts it (just) outside the required range. A possible offshot TODO for me for the VRT driver 'vrt://...?a_ullr', or we could expand the bounds allowed.

gdalinfo ../autotest/gdrivers/data/netcdf/longitude_latitude.nc 

Tasklist

  • add open option as well as config option
  • Add test case(s)
  • Add documentation
  • Review
  • Adjust for comments
  • All CI builds and checks have passed

@mdsumner mdsumner marked this pull request as draft December 13, 2022 11:11
@mdsumner mdsumner marked this pull request as ready for review December 14, 2022 21:30
Co-authored-by: Even Rouault <even.rouault@spatialys.com>
autotest/gdrivers/netcdf.py Outdated Show resolved Hide resolved
autotest/gdrivers/netcdf.py Outdated Show resolved Hide resolved
frmts/netcdf/netcdfdataset.cpp Outdated Show resolved Hide resolved
doc/source/drivers/raster/netcdf.rst Outdated Show resolved Hide resolved
doc/source/drivers/raster/netcdf.rst Outdated Show resolved Hide resolved
mdsumner and others added 5 commits December 16, 2022 06:46
Co-authored-by: Even Rouault <even.rouault@spatialys.com>
Co-authored-by: Even Rouault <even.rouault@spatialys.com>
Co-authored-by: Even Rouault <even.rouault@spatialys.com>
Co-authored-by: Even Rouault <even.rouault@spatialys.com>
Co-authored-by: Even Rouault <even.rouault@spatialys.com>
@rouault rouault merged commit a733bf0 into OSGeo:master Dec 15, 2022
@rouault rouault added this to the 3.7.0 milestone Dec 15, 2022
@rouault
Copy link
Member

rouault commented Dec 15, 2022

squashed & merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants