Opened 7 years ago
Closed 6 years ago
#3498 closed defect (fixed)
Can't open NetCDF file
Reported by: | mankoff | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 7.4.2 |
Component: | Default | Version: | 7.4.0 |
Keywords: | Cc: | ||
CPU: | Unspecified | Platform: | MacOSX |
Description ¶
In GRASS 7.2.2 I can read a netCDF file:
r.in.gdal -o input=netCDF:${ROOT}/MOD6_2000.nc:gld band=1 output=tmp --o WARNING: Over-riding projection check Proceeding with import of 366 raster bands... Importing raster map <tmp>...
In GRASS 7.4.0, I cannot:
r.in.gdal -o input=netCDF:${ROOT}/MOD6_2000.nc:gld band=1 output=tmp --o ERROR 10: Pointer 'hSRS' is NULL in 'OSRIsProjected'. ERROR 10: Pointer 'hSRS' is NULL in 'OSRIsGeographic'. Input contains an invalid SRS. WKT definition: PROJCS[ WARNING: Unable to convert input map projection information to GRASS format.
Same file, same GRASS location.
Google finds 0 results for the string "Pointer 'hSRS' is NULL in 'OSRIsProjected'", so I'm not even sure what project (GRASS, proj, gdal) might be causing this problem. Sample file is attached.
Change History (8)
by , 7 years ago
comment:1 by , 7 years ago
Replying to mankoff:
In GRASS 7.2.2 I can read a netCDF file:
r.in.gdal -o input=netCDF:${ROOT}/MOD6_2000.nc:gld band=1 output=tmp --o WARNING: Over-riding projection check Proceeding with import of 366 raster bands... Importing raster map <tmp>...In GRASS 7.4.0, I cannot:
r.in.gdal -o input=netCDF:${ROOT}/MOD6_2000.nc:gld band=1 output=tmp --o ERROR 10: Pointer 'hSRS' is NULL in 'OSRIsProjected'. ERROR 10: Pointer 'hSRS' is NULL in 'OSRIsGeographic'. Input contains an invalid SRS. WKT definition: PROJCS[ WARNING: Unable to convert input map projection information to GRASS format.Same file, same GRASS location.
Google finds 0 results for the string "Pointer 'hSRS' is NULL in 'OSRIsProjected'", so I'm not even sure what project (GRASS, proj, gdal) might be causing this problem. Sample file is attached.
which EPSG/projection has this dataset?
gdalinfo says
polar_stereographic#false_easting=0 polar_stereographic#false_northing=0 polar_stereographic#GeoTransform=-653000 4992.671009771987 0 -632500 0 -5003.636363636364 polar_stereographic#grid_mapping_name=polar_stereographic polar_stereographic#inverse_flattening=298.257223563 polar_stereographic#latitude_of_projection_origin=90 polar_stereographic#longitude_of_prime_meridian=0 polar_stereographic#long_name=CRS definition polar_stereographic#semi_major_axis=6378137 polar_stereographic#spatial_ref=PROJCS[ polar_stereographic#standard_parallel=70 polar_stereographic#straight_vertical_longitude_from_pole=-45
follow-up: 4 comment:2 by , 7 years ago
The data set was generated by exporting the (lon,lat) of each cell from a GRASS EPSG:3413 location and mapset to a NetCDF file, and then using the cdo remapbil
function to convert a rotated-pole netCDF file to this grid.
g.region -p projection: 99 (WGS 84 / NSIDC Sea Ice Polar Stereographic North) zone: 0 datum: wgs84 ellipsoid: wgs84 north: -630000 south: -3385000 west: -655000 east: 880000 nsres: 5000 ewres: 5000 rows: 551 cols: 307 cells: 169157
And
g.proj -j +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +no_defs +a=6378137 +rf=298.257223563 +towgs84=0.000,0.000,0.000 +to_meter=1
comment:3 by , 7 years ago
And the reason the projection is slightly different than your gdalinfo
output is because since I posted the file I realized I need to set the -a
flag to g.region
so that the resolution is not rounded to a strange number. My gdalinfo
output contains:
polar_stereographic#false_easting=0 polar_stereographic#false_northing=0 polar_stereographic#GeoTransform=-655000 5000 0 -630000 0 -5000 polar_stereographic#grid_mapping_name=polar_stereographic polar_stereographic#inverse_flattening=298.257223563 polar_stereographic#latitude_of_projection_origin=90 polar_stereographic#longitude_of_prime_meridian=0 polar_stereographic#long_name=CRS definition polar_stereographic#semi_major_axis=6378137 polar_stereographic#spatial_ref=PROJCS[ polar_stereographic#standard_parallel=70 polar_stereographic#straight_vertical_longitude_from_pole=-45
Note that regardless of this, I'm using the -o
flag to r.in.gdal
, and it works in grass 7.2.0. I thought the -o
flag means the projection information, which may or may not be present and/or correct, is ignored.
follow-up: 5 comment:4 by , 7 years ago
Replying to mankoff:
g.proj -j +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +no_defs +a=6378137 +rf=298.257223563 +towgs84=0.000,0.000,0.000 +to_meter=1
no 7.2.2 available here for testing.
location created by the above proj4 string, now here also
g.proj -j +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +no_defs +a=6378137 +rf=298.257223563 +towgs84=0,0,0,0,0,0,0 +to_meter=1
tested with
GRASS version: 7.4.0 GRASS SVN revision: r72154 Build date: 2018-01-27 Build platform: x86_64-w64-mingw32 GDAL: 2.2.3 PROJ.4: 4.9.3 GEOS: 3.5.0 SQLite: 3.17.0 Python: 2.7.5 wxPython: 2.8.12.1 Platform: Windows-8-6.2.9200 (OSGeo4W)
r.in.gdal -o input=D:\temp\nc\foo.nc output=band1 band=1 ERROR 10: Pointer 'hSRS' is NULL in 'OSRIsProjected'. ERROR 10: Pointer 'hSRS' is NULL in 'OSRIsGeographic'. WARNING: Input contains subdatasets which may need to be imported separately Input contains an invalid SRS. WKT definition: PROJCS[ WARNING: Unable to convert input map projection information to GRASS format. Over-riding projection check Importing 366 raster bands... Importing raster map <band1>...
and
GRASS version: 7.5.svn GRASS SVN revision: r72230 Build date: 2018-01-12 Build platform: x86_64-w64-mingw32 GDAL: 2.2.3 PROJ.4: 4.9.3 GEOS: 3.5.0 SQLite: 3.17.0 Python: 2.7.5 wxPython: 2.8.12.1 Platform: Windows-8-6.2.9200 (OSGeo4W)
r.in.gdal -o input=D:\temp\nc\foo.nc output=band2 band=2 ERROR 10: Pointer 'hSRS' is NULL in 'OSRIsProjected'. ERROR 10: Pointer 'hSRS' is NULL in 'OSRIsGeographic'. WARNING: Input contains subdatasets which may need to be imported separately Input contains an invalid SRS. WKT definition: PROJCS[ WARNING: Unable to convert input map projection information to GRASS format. Over-riding projection check Importing 366 raster bands... Importing raster map <band2>...
though there is this error, the band seems to be imported.
wasn't there already a similar error with stere?
comment:5 by , 7 years ago
Replying to hellik:
r.in.gdal -o input=D:\temp\nc\foo.nc output=band2 band=2 ERROR 10: Pointer 'hSRS' is NULL in 'OSRIsProjected'. ERROR 10: Pointer 'hSRS' is NULL in 'OSRIsGeographic'. WARNING: Input contains subdatasets which may need to be imported separately Input contains an invalid SRS. WKT definition:
This is the projection info as recognized by GDAL:
PROJCS[
it's incomplete.
WARNING: Unable to convert input map projection information to GRASS format. Over-riding projection check Importing 366 raster bands... Importing raster map <band2>...though there is this error, the band seems to be imported.
Yes, the error comes from GDAL and is not fatal, the band is still imported.
Anyway, I have fixed this error in r72251,2 (trunk, relbr74).
comment:6 by , 7 years ago
Milestone: | 7.4.1 → 7.4.2 |
---|
comment:7 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Seems to be solved. Feel free to reopen if needed.
sample file