[GRASS-user] Cannot read NetCDF with 'semi_major_axis' or 'inverse_flattening'

Hello list,

I have been given an updated NetCDF file - everything is the same as the old version except there are two new attributes in the 'mapping' variable:

        char mapping ;
                mapping:geoid = "eigen-6c4" ;
                mapping:grid_mapping_name = "polar_stereographic" ;
                mapping:latitude_of_projection_origin = 90. ;
                mapping:standard_parallel = 70. ;
                mapping:straight_vertical_longitude_from_pole = -45. ;
                mapping:semi_major_axis = 6378273. ;
                mapping:inverse_flattening = 298.27940504282 ;
                mapping:false_easting = 0. ;
                mapping:false_northing = 0. ;
                mapping:_Storage = "contiguous" ;

Specifically:
                mapping:semi_major_axis = 6378273. ;
                mapping:inverse_flattening = 298.27940504282 ;

When I try to load this file with:

r.external source=netCDF:file.nc:surface output=surface

I get this error:

WARNING: Datum <unnamed> not recognised by GRASS and no parameters found
ERROR: Projection of dataset does not appear to match current location.

Location PROJ_INFO is:
name: WGS 84 / NSIDC Sea Ice Polar Stereographic North
datum: wgs84
ellps: wgs84
proj: stere
lat_0: 90
lat_ts: 70
lon_0: -45
x_0: 0
y_0: 0
no_defs: defined
init: EPSG:3413

Dataset PROJ_INFO is:
name: unnamed
a: 6378273
es: 0.006693883000000017
proj: stere
lat_0: 90
lat_ts: 70
lon_0: -45
x_0: 0
y_0: 0
no_defs: defined

ERROR: datum

In case of no significant differences in the projection definitions, use the -o flag to ignore them and use current location definition.
Consider generating a new location from the input dataset using the 'location' parameter.

If I remove thos two attributes (semi_major_axis and inverse_flattening) with:

ncatted -O -h -a semi_major_axis,mapping,d,l,6378273 -a inverse_flattening,mapping,d,f,298.27940504282 file.nc foo.nc

And then try to read in the data, it works.

Is there some reason that those two attributes make it difficult to load the data in GRASS? Is there a better work-around than removing them? The documented projection of the data has not changed, only some of the metadata.

Versions:
gdal 3.0.4
grass 7.8.2

Thank you,

   -k.

Hei Ken,

Did you try the -o flag ("Override projection check (use current location's projection)
Assume that the dataset has same projection as the current location")?
https://grass.osgeo.org/grass78/manuals/r.external.html
As the error message suggests?

If you are sure that projections in fact match, a mismatch in CRS description can be overridden that way, without modifying the input file.

Alternatively, you can use r.import to reproject while converting to GRASS format or you create a new location...

Cheers
Stefan

-----Original Message-----
From: grass-user <grass-user-bounces@lists.osgeo.org> On Behalf Of Ken Mankoff
Sent: fredag 23. juli 2021 19:33
To: GRASS user list <grass-user@lists.osgeo.org>
Subject: [GRASS-user] Cannot read NetCDF with 'semi_major_axis' or 'inverse_flattening'

Hello list,

I have been given an updated NetCDF file - everything is the same as the old version except there are two new attributes in the 'mapping' variable:

        char mapping ;
                mapping:geoid = "eigen-6c4" ;
                mapping:grid_mapping_name = "polar_stereographic" ;
                mapping:latitude_of_projection_origin = 90. ;
                mapping:standard_parallel = 70. ;
                mapping:straight_vertical_longitude_from_pole = -45. ;
                mapping:semi_major_axis = 6378273. ;
                mapping:inverse_flattening = 298.27940504282 ;
                mapping:false_easting = 0. ;
                mapping:false_northing = 0. ;
                mapping:_Storage = "contiguous" ;

Specifically:
                mapping:semi_major_axis = 6378273. ;
                mapping:inverse_flattening = 298.27940504282 ;

When I try to load this file with:

r.external source=netCDF:file.nc:surface output=surface

I get this error:

WARNING: Datum <unnamed> not recognised by GRASS and no parameters found
ERROR: Projection of dataset does not appear to match current location.

Location PROJ_INFO is:
name: WGS 84 / NSIDC Sea Ice Polar Stereographic North
datum: wgs84
ellps: wgs84
proj: stere
lat_0: 90
lat_ts: 70
lon_0: -45
x_0: 0
y_0: 0
no_defs: defined
init: EPSG:3413

Dataset PROJ_INFO is:
name: unnamed
a: 6378273
es: 0.006693883000000017
proj: stere
lat_0: 90
lat_ts: 70
lon_0: -45
x_0: 0
y_0: 0
no_defs: defined

ERROR: datum

In case of no significant differences in the projection definitions, use the -o flag to ignore them and use current location definition.
Consider generating a new location from the input dataset using the 'location' parameter.

If I remove thos two attributes (semi_major_axis and inverse_flattening) with:

ncatted -O -h -a semi_major_axis,mapping,d,l,6378273 -a inverse_flattening,mapping,d,f,298.27940504282 file.nc foo.nc

And then try to read in the data, it works.

Is there some reason that those two attributes make it difficult to load the data in GRASS? Is there a better work-around than removing them? The documented projection of the data has not changed, only some of the metadata.

Versions:
gdal 3.0.4
grass 7.8.2

Thank you,

   -k.

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.osgeo.org%2Fmailman%2Flistinfo%2Fgrass-user&amp;data=04|01||900b853648c545edd6fd08d94dffe4cb|6cef373021314901831055b3abf02c73|0|0|637626583719044920|Unknown|TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D|1000&amp;sdata=wWKyBuAKwbuobSGVQ6q97VXj1OIiCLSN9NlbXDLw7tc%3D&amp;reserved=0

Hi Stefan,

Thanks for the hint. I often use ‘-o’. In this case after discussion with the data provider it turns out that it was not EPSG:3413 but instead some custom projection, even though part of the NetCDF file reported EPSG:3413 in the metadata.

Unfortunately r.import does not work. I get the errors below. Given the 0…3…6…9… it appears to import something, but no raster exists when the command finishes.

r.import input=NetCDF:file.nc:surface output=surface
WARNING: Datum not recognised by GRASS and no parameters found
WARNING: Projection of dataset does not appear to match current location.

Location PROJ_INFO is:
name: WGS 84 / NSIDC Sea Ice Polar Stereographic North
datum: wgs84
ellps: wgs84
proj: stere
lat_0: 90
lat_ts: 70
lon_0: -45
x_0: 0
y_0: 0
no_defs: defined
init: EPSG:3413

Dataset PROJ_INFO is:
name: unnamed
a: 6378273
es: 0.006693883000000017
proj: stere
lat_0: 90
lat_ts: 70
lon_0: -45
x_0: 0
y_0: 0
no_defs: defined

ERROR: datum

WARNING: Datum not recognised by GRASS and no parameters found
WARNING: Datum not recognised by GRASS and no parameters found
Importing raster map …
0…3…6…9…12…15…18…21…24…27…30…33…36…39…42…45…48…51…54…57…60…63…66…69…72…75…78…81…84…87…90…93…96…99…100
ERROR: Unable to open element file for tmp.r.import.3257873@PERMANENT
ERROR: Unable to get reprojected map extent

-k.

On Sat, Jul 24, 2021 at 2:19 PM Stefan Blumentrath <Stefan.Blumentrath@nina.no> wrote:

Hei Ken,

Did you try the -o flag (“Override projection check (use current location’s projection)
Assume that the dataset has same projection as the current location”)?
https://grass.osgeo.org/grass78/manuals/r.external.html
As the error message suggests?

If you are sure that projections in fact match, a mismatch in CRS description can be overridden that way, without modifying the input file.

Alternatively, you can use r.import to reproject while converting to GRASS format or you create a new location…

Cheers
Stefan

-----Original Message-----
From: grass-user <grass-user-bounces@lists.osgeo.org> On Behalf Of Ken Mankoff
Sent: fredag 23. juli 2021 19:33
To: GRASS user list <grass-user@lists.osgeo.org>
Subject: [GRASS-user] Cannot read NetCDF with ‘semi_major_axis’ or ‘inverse_flattening’

Hello list,

I have been given an updated NetCDF file - everything is the same as the old version except there are two new attributes in the ‘mapping’ variable:

char mapping ;
mapping:geoid = “eigen-6c4” ;
mapping:grid_mapping_name = “polar_stereographic” ;
mapping:latitude_of_projection_origin = 90. ;
mapping:standard_parallel = 70. ;
mapping:straight_vertical_longitude_from_pole = -45. ;
mapping:semi_major_axis = 6378273. ;
mapping:inverse_flattening = 298.27940504282 ;
mapping:false_easting = 0. ;
mapping:false_northing = 0. ;
mapping:_Storage = “contiguous” ;

Specifically:
mapping:semi_major_axis = 6378273. ;
mapping:inverse_flattening = 298.27940504282 ;

When I try to load this file with:

r.external source=netCDF:file.nc:surface output=surface

I get this error:

WARNING: Datum not recognised by GRASS and no parameters found
ERROR: Projection of dataset does not appear to match current location.

Location PROJ_INFO is:
name: WGS 84 / NSIDC Sea Ice Polar Stereographic North
datum: wgs84
ellps: wgs84
proj: stere
lat_0: 90
lat_ts: 70
lon_0: -45
x_0: 0
y_0: 0
no_defs: defined
init: EPSG:3413

Dataset PROJ_INFO is:
name: unnamed
a: 6378273
es: 0.006693883000000017
proj: stere
lat_0: 90
lat_ts: 70
lon_0: -45
x_0: 0
y_0: 0
no_defs: defined

ERROR: datum

In case of no significant differences in the projection definitions, use the -o flag to ignore them and use current location definition.
Consider generating a new location from the input dataset using the ‘location’ parameter.

If I remove thos two attributes (semi_major_axis and inverse_flattening) with:

ncatted -O -h -a semi_major_axis,mapping,d,l,6378273 -a inverse_flattening,mapping,d,f,298.27940504282 file.nc foo.nc

And then try to read in the data, it works.

Is there some reason that those two attributes make it difficult to load the data in GRASS? Is there a better work-around than removing them? The documented projection of the data has not changed, only some of the metadata.

Versions:
gdal 3.0.4
grass 7.8.2

Thank you,

-k.


grass-user mailing list
grass-user@lists.osgeo.org
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.osgeo.org%2Fmailman%2Flistinfo%2Fgrass-user&data=04%7C01%7C%7C900b853648c545edd6fd08d94dffe4cb%7C6cef373021314901831055b3abf02c73%7C0%7C0%7C637626583719044920%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=wWKyBuAKwbuobSGVQ6q97VXj1OIiCLSN9NlbXDLw7tc%3D&reserved=0

Ok - just to clear this up and shut down this thread. It turns out it is EPSG:3411 but was reported as 3413. I can import (with -o) into a 3411 location, and then reproject.

Cheers,

-k.

On Sun, Jul 25, 2021 at 8:45 PM Ken Mankoff <mankoff@gmail.com> wrote:

Hi Stefan,

Thanks for the hint. I often use ‘-o’. In this case after discussion with the data provider it turns out that it was not EPSG:3413 but instead some custom projection, even though part of the NetCDF file reported EPSG:3413 in the metadata.

Unfortunately r.import does not work. I get the errors below. Given the 0…3…6…9… it appears to import something, but no raster exists when the command finishes.

r.import input=NetCDF:file.nc:surface output=surface
WARNING: Datum not recognised by GRASS and no parameters found
WARNING: Projection of dataset does not appear to match current location.

Location PROJ_INFO is:
name: WGS 84 / NSIDC Sea Ice Polar Stereographic North
datum: wgs84
ellps: wgs84
proj: stere
lat_0: 90
lat_ts: 70
lon_0: -45
x_0: 0
y_0: 0
no_defs: defined
init: EPSG:3413

Dataset PROJ_INFO is:
name: unnamed
a: 6378273
es: 0.006693883000000017
proj: stere
lat_0: 90
lat_ts: 70
lon_0: -45
x_0: 0
y_0: 0
no_defs: defined

ERROR: datum

WARNING: Datum not recognised by GRASS and no parameters found
WARNING: Datum not recognised by GRASS and no parameters found
Importing raster map …
0…3…6…9…12…15…18…21…24…27…30…33…36…39…42…45…48…51…54…57…60…63…66…69…72…75…78…81…84…87…90…93…96…99…100
ERROR: Unable to open element file for tmp.r.import.3257873@PERMANENT
ERROR: Unable to get reprojected map extent

-k.

On Sat, Jul 24, 2021 at 2:19 PM Stefan Blumentrath <Stefan.Blumentrath@nina.no> wrote:

Hei Ken,

Did you try the -o flag (“Override projection check (use current location’s projection)
Assume that the dataset has same projection as the current location”)?
https://grass.osgeo.org/grass78/manuals/r.external.html
As the error message suggests?

If you are sure that projections in fact match, a mismatch in CRS description can be overridden that way, without modifying the input file.

Alternatively, you can use r.import to reproject while converting to GRASS format or you create a new location…

Cheers
Stefan

-----Original Message-----
From: grass-user <grass-user-bounces@lists.osgeo.org> On Behalf Of Ken Mankoff
Sent: fredag 23. juli 2021 19:33
To: GRASS user list <grass-user@lists.osgeo.org>
Subject: [GRASS-user] Cannot read NetCDF with ‘semi_major_axis’ or ‘inverse_flattening’

Hello list,

I have been given an updated NetCDF file - everything is the same as the old version except there are two new attributes in the ‘mapping’ variable:

char mapping ;
mapping:geoid = “eigen-6c4” ;
mapping:grid_mapping_name = “polar_stereographic” ;
mapping:latitude_of_projection_origin = 90. ;
mapping:standard_parallel = 70. ;
mapping:straight_vertical_longitude_from_pole = -45. ;
mapping:semi_major_axis = 6378273. ;
mapping:inverse_flattening = 298.27940504282 ;
mapping:false_easting = 0. ;
mapping:false_northing = 0. ;
mapping:_Storage = “contiguous” ;

Specifically:
mapping:semi_major_axis = 6378273. ;
mapping:inverse_flattening = 298.27940504282 ;

When I try to load this file with:

r.external source=netCDF:file.nc:surface output=surface

I get this error:

WARNING: Datum not recognised by GRASS and no parameters found
ERROR: Projection of dataset does not appear to match current location.

Location PROJ_INFO is:
name: WGS 84 / NSIDC Sea Ice Polar Stereographic North
datum: wgs84
ellps: wgs84
proj: stere
lat_0: 90
lat_ts: 70
lon_0: -45
x_0: 0
y_0: 0
no_defs: defined
init: EPSG:3413

Dataset PROJ_INFO is:
name: unnamed
a: 6378273
es: 0.006693883000000017
proj: stere
lat_0: 90
lat_ts: 70
lon_0: -45
x_0: 0
y_0: 0
no_defs: defined

ERROR: datum

In case of no significant differences in the projection definitions, use the -o flag to ignore them and use current location definition.
Consider generating a new location from the input dataset using the ‘location’ parameter.

If I remove thos two attributes (semi_major_axis and inverse_flattening) with:

ncatted -O -h -a semi_major_axis,mapping,d,l,6378273 -a inverse_flattening,mapping,d,f,298.27940504282 file.nc foo.nc

And then try to read in the data, it works.

Is there some reason that those two attributes make it difficult to load the data in GRASS? Is there a better work-around than removing them? The documented projection of the data has not changed, only some of the metadata.

Versions:
gdal 3.0.4
grass 7.8.2

Thank you,

-k.


grass-user mailing list
grass-user@lists.osgeo.org
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.osgeo.org%2Fmailman%2Flistinfo%2Fgrass-user&data=04%7C01%7C%7C900b853648c545edd6fd08d94dffe4cb%7C6cef373021314901831055b3abf02c73%7C0%7C0%7C637626583719044920%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=wWKyBuAKwbuobSGVQ6q97VXj1OIiCLSN9NlbXDLw7tc%3D&reserved=0