Skip to content

Commit

Permalink
Merge pull request #11010 from rouault/fix_11009
Browse files Browse the repository at this point in the history
netCDF: do not emit error when longitude axis unit is degrees_east and latitude axis unit is degrees_north
  • Loading branch information
rouault authored Oct 15, 2024
2 parents acff832 + 7c649cd commit bc29ea0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions autotest/gdrivers/netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,9 @@ def test_netcdf_11():

def test_netcdf_cf_geog_with_srs():

gdal.ErrorReset()
ds = gdal.Open("data/netcdf/cf_geog_with_srs.nc")
assert gdal.GetLastErrorMsg() == ""

gt = ds.GetGeoTransform()
assert gt == pytest.approx([-0.1, 0.2, 0, -79.1, 0, -0.2], rel=1e-5)
Expand Down
6 changes: 6 additions & 0 deletions frmts/netcdf/netcdfdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3470,6 +3470,12 @@ void netCDFDataset::SetProjectionFromVar(
{
const char *pszUnitsX = FetchAttr(nGroupDimXID, nVarDimXID, "units");
const char *pszUnitsY = FetchAttr(nGroupDimYID, nVarDimYID, "units");
// Normalize degrees_east/degrees_north to degrees
// Cf https://github.com/OSGeo/gdal/issues/11009
if (pszUnitsX && EQUAL(pszUnitsX, "degrees_east"))
pszUnitsX = "degrees";
if (pszUnitsY && EQUAL(pszUnitsY, "degrees_north"))
pszUnitsY = "degrees";

if (pszUnitsX && pszUnitsY)
{
Expand Down

0 comments on commit bc29ea0

Please sign in to comment.