[gdal-dev] netCDF vector driver reading CF-1.6 point featureType with time coordinate variable

Jesse Bickel - NOAA Affiliate jesse.bickel at noaa.gov
Wed Mar 31 12:54:37 PDT 2021


Hello,

When using the netCDF vector driver to read CF-1.6 point features, it appears
a netCDF time coordinate variable prevents OGR layers from being produced. When
the time variable units are changed to fake units, such as meters, layers are
then produced.

Attached are two example CDL files and two netCDF 3 files produced from the
CDL files. From the below log one can see the layer count 1 for the netCDF data
labeled "ogr_layer_produced" and layer count 0 for the netCDF data labeled
"ogr_layer_not_produced" for GDAL/OGR version 3.2.1. The effect in a downstream
tool such as QGIS is success or failure in reading a GIS layer from the netCDF.

I see the warning about sharing a primary dimension, but I do not see such a
requirement in the CF conventions. It would be preferred to allow layers to be
produced for the latter variables when there is a time coordinate variable
present as a time variable.

Thank you for your consideration,

Jesse

--
Contractor, ERT, Inc.
Federal Affiliation: NWC/OWP/NOAA/DOC

-------------- next part --------------
netcdf ogr_layer_produced {
dimensions:
	geo = 3 ;
	duration = 1 ;
	time = 1 ;
	name_string_len = 2 ;
	long_string_len = 20 ;
variables:
	int ProjectionCoordinateSystem ;
		ProjectionCoordinateSystem:long_name = "CRS definition" ;
		ProjectionCoordinateSystem:grid_mapping_name = "latitude_longitude" ;
		ProjectionCoordinateSystem:spatial_ref = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]" ;
		ProjectionCoordinateSystem:longitude_of_prime_meridian = 0. ;
		ProjectionCoordinateSystem:semi_major_axis = 6378137. ;
		ProjectionCoordinateSystem:inverse_flattening = 298.257223563 ;
		ProjectionCoordinateSystem:proj4 = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" ;
	int duration(duration) ;
		duration:units = "meters" ;
		duration:long_name = "The duration associated with all values in variables of interest." ;
		duration:notes = "Purposely avoided setting true units and standard_name attributes to maintain compatibility with GDAL/OGR 3.0.4 and QGIS 3.10.5." ;
	double lat(geo) ;
		lat:units = "degrees_north" ;
		lat:standard_name = "latitude" ;
		lat:long_name = "latitude" ;
		lat:axis = "Y" ;
		lat:_FillValue = 9.96920996838687e+36 ;
		lat:missing_value = 9.96920996838687e+36 ;
	double lon(geo) ;
		lon:units = "degrees_east" ;
		lon:standard_name = "longitude" ;
		lon:long_name = "longitude" ;
		lon:axis = "X" ;
		lon:_FillValue = 9.96920996838687e+36 ;
		lon:missing_value = 9.96920996838687e+36 ;
	char long_name(geo, long_string_len) ;
		long_name:coordinates = "lon lat" ;
		long_name:grid_mapping = "ProjectionCoordinateSystem" ;
		long_name:long_name = "The long name of the geo." ;
	char name(geo, name_string_len) ;
		name:coordinates = "lon lat" ;
		name:grid_mapping = "ProjectionCoordinateSystem" ;
		name:long_name = "The short name of the geo." ;
	int time(time) ;
		time:units = "meters" ;
		time:long_name = "minutes since 1970-01-01T00:00:00Z" ;
		time:notes = "Purposely avoided setting true units and standard_name attributes to maintain compatibility with GDAL/OGR 3.0.4 and QGIS 3.10.5." ;
	double VARIABLE_OF_INTEREST_1(geo) ;
		VARIABLE_OF_INTEREST_1:_FillValue = 9.96920996838687e+36 ;
		VARIABLE_OF_INTEREST_1:missing_value = 9.96920996838687e+36 ;
		VARIABLE_OF_INTEREST_1:long_name = "The first variable to plot." ;
		VARIABLE_OF_INTEREST_1:measurement_unit = "feet" ;
		VARIABLE_OF_INTEREST_1:grid_mapping = "ProjectionCoordinateSystem" ;
		VARIABLE_OF_INTEREST_1:coordinates = "lon lat" ;
	double VARIABLE_OF_INTEREST_2(geo) ;
		VARIABLE_OF_INTEREST_2:_FillValue = 9.96920996838687e+36 ;
		VARIABLE_OF_INTEREST_2:missing_value = 9.96920996838687e+36 ;
		VARIABLE_OF_INTEREST_2:long_name = "The second variable to plot." ;
		VARIABLE_OF_INTEREST_2:measurement_unit = "feet" ;
		VARIABLE_OF_INTEREST_2:grid_mapping = "ProjectionCoordinateSystem" ;
		VARIABLE_OF_INTEREST_2:coordinates = "lon lat" ;

// global attributes:
		:Conventions = "CF-1.6" ;
		:featureType = "point" ;
data:

 ProjectionCoordinateSystem = _ ;

 duration = 120 ;

 lat = 37.0, 35.0, 36.0 ;

 lon = -97.0, -97.5, -97.8 ;

 long_name =
  "1111111111_AAAAAAAAA",
  "2222222222_BBBBBBBBB",
  "3333333333_CCCCCCCCC" ;

 name =
  "1A",
  "2B",
  "3C" ;

 time = 26852709 ;

 VARIABLE_OF_INTEREST_1 = 0.344485291636462, 0.155167470401714, 
    0.0597629903227599 ;

 VARIABLE_OF_INTEREST_2 = 24, 13, 23 ;
}
-------------- next part --------------

-------------- next part --------------
netcdf ogr_layer_not_produced {
dimensions:
	geo = 3 ;
	duration = 1 ;
	time = 1 ;
	name_string_len = 2 ;
	long_string_len = 20 ;
variables:
	int ProjectionCoordinateSystem ;
		ProjectionCoordinateSystem:long_name = "CRS definition" ;
		ProjectionCoordinateSystem:grid_mapping_name = "latitude_longitude" ;
		ProjectionCoordinateSystem:spatial_ref = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]" ;
		ProjectionCoordinateSystem:longitude_of_prime_meridian = 0. ;
		ProjectionCoordinateSystem:semi_major_axis = 6378137. ;
		ProjectionCoordinateSystem:inverse_flattening = 298.257223563 ;
		ProjectionCoordinateSystem:proj4 = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" ;
	int duration(duration) ;
		duration:units = "minutes" ;
		duration:standard_name = "time" ;
		duration:long_name = "The duration associated with all values in variables of interest." ;
	double lat(geo) ;
		lat:units = "degrees_north" ;
		lat:standard_name = "latitude" ;
		lat:long_name = "latitude" ;
		lat:axis = "Y" ;
		lat:_FillValue = 9.96920996838687e+36 ;
		lat:missing_value = 9.96920996838687e+36 ;
	double lon(geo) ;
		lon:units = "degrees_east" ;
		lon:standard_name = "longitude" ;
		lon:long_name = "longitude" ;
		lon:axis = "X" ;
		lon:_FillValue = 9.96920996838687e+36 ;
		lon:missing_value = 9.96920996838687e+36 ;
	char long_name(geo, long_string_len) ;
		long_name:coordinates = "lon lat" ;
		long_name:grid_mapping = "ProjectionCoordinateSystem" ;
		long_name:long_name = "The long name of the geo." ;
	char name(geo, name_string_len) ;
		name:coordinates = "lon lat" ;
		name:grid_mapping = "ProjectionCoordinateSystem" ;
		name:long_name = "The short name of the geo." ;
	int time(time) ;
		time:units = "minutes since 1970-01-01T00:00:00Z" ;
		time:standard_name = "time" ;
		time:long_name = "The datetime associated with all values in variables of interest." ;
	double VARIABLE_OF_INTEREST_1(geo) ;
		VARIABLE_OF_INTEREST_1:_FillValue = 9.96920996838687e+36 ;
		VARIABLE_OF_INTEREST_1:missing_value = 9.96920996838687e+36 ;
		VARIABLE_OF_INTEREST_1:long_name = "The first variable to plot." ;
		VARIABLE_OF_INTEREST_1:measurement_unit = "feet" ;
		VARIABLE_OF_INTEREST_1:grid_mapping = "ProjectionCoordinateSystem" ;
		VARIABLE_OF_INTEREST_1:coordinates = "lon lat" ;
	double VARIABLE_OF_INTEREST_2(geo) ;
		VARIABLE_OF_INTEREST_2:_FillValue = 9.96920996838687e+36 ;
		VARIABLE_OF_INTEREST_2:missing_value = 9.96920996838687e+36 ;
		VARIABLE_OF_INTEREST_2:long_name = "The second variable to plot." ;
		VARIABLE_OF_INTEREST_2:measurement_unit = "feet" ;
		VARIABLE_OF_INTEREST_2:grid_mapping = "ProjectionCoordinateSystem" ;
		VARIABLE_OF_INTEREST_2:coordinates = "lon lat" ;

// global attributes:
		:Conventions = "CF-1.6" ;
		:featureType = "point" ;
data:

 ProjectionCoordinateSystem = _ ;

 duration = 120 ;

 lat = 37.0, 35.0, 36.0 ;

 lon = -97.0, -97.5, -97.8 ;

 long_name =
  "1111111111_AAAAAAAAA",
  "2222222222_BBBBBBBBB",
  "3333333333_CCCCCCCCC" ;

 name =
  "1A",
  "2B",
  "3C" ;

 time = 26852709 ;

 VARIABLE_OF_INTEREST_1 = 0.344485291636462, 0.155167470401714, 
    0.0597629903227599 ;

 VARIABLE_OF_INTEREST_2 = 24, 13, 23 ;
}
-------------- next part --------------

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ogr_layer_produced.nc
Type: application/octet-stream
Size: 2968 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210331/82a07df0/attachment.obj>
-------------- next part --------------

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ogr_layer_not_produced.nc
Type: application/octet-stream
Size: 2796 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210331/82a07df0/attachment-0001.obj>
-------------- next part --------------



User.Name at MACHINE-NAME /cygdrive/C/Users/User.Name/code/gdal-3.2.1/apps
$ CPL_DEBUG=ON ./ogrinfo.exe ../../../Downloads/ogr_layer_produced.nc
GDAL_netCDF: driver detected file type=1, libnetcdf detected type=1
GDAL_netCDF: var_count = 9
GDAL_netCDF:
=====
SetProjectionFromVar( 65536, 4)
GDAL_netCDF: got grid_mapping ProjectionCoordinateSystem
GDAL_netCDF: bIsGdalFile=0 bIsGdalCfFile=0 bSwitchedXY=0 bBottomUp=1
GDAL_netCDF: got spheroid from CF: (6378137.000000 , 298.257224)
GDAL_netCDF: setting WKT from CF
GDAL_netCDF: setting WKT from GDAL
GDAL_netCDF: SetProjection, WKT = GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]
GDAL_netCDF: Got SRS but no geotransform from GDAL!
GDAL: GDALOpen(../../../Downloads/ogr_layer_produced.nc, this=0x8000dafa0) succeeds as netCDF.
INFO: Open of `../../../Downloads/ogr_layer_produced.nc'
      using driver `netCDF' successful.
OGR: GetLayerCount() = 1

1: ogr_layer_produced (Point)
GDAL: GDALClose(../../../Downloads/ogr_layer_produced.nc, this=0x8000dafa0)
GDAL: In GDALDestroy - unloading GDAL shared library.

User.Name at MACHINE-NAME /cygdrive/C/Users/User.Name/code/gdal-3.2.1/apps
$ CPL_DEBUG=ON ./ogrinfo.exe ../../../Downloads/ogr_layer_not_produced.nc
GDAL_netCDF: driver detected file type=1, libnetcdf detected type=1
GDAL_netCDF: var_count = 9
Warning 1: The dataset has several variables that could be identified as vector fields, but not all share the same primary dimension. Consequently they will be ignored.
GDAL_netCDF: driver detected file type=1, libnetcdf detected type=1
GDAL_netCDF: var_count = 9
Warning 1: The dataset has several variables that could be identified as vector fields, but not all share the same primary dimension. Consequently they will be ignored.
GDAL: GDALOpen(../../../Downloads/ogr_layer_not_produced.nc, this=0x8000db3b0) succeeds as netCDF.
INFO: Open of `../../../Downloads/ogr_layer_not_produced.nc'
      using driver `netCDF' successful.
Metadata:
  NC_GLOBAL#Conventions=CF-1.6
  NC_GLOBAL#featureType=point
OGR: GetLayerCount() = 0

GDAL: GDALClose(../../../Downloads/ogr_layer_not_produced.nc, this=0x8000db3b0)
GDAL: In GDALDestroy - unloading GDAL shared library.


More information about the gdal-dev mailing list