GeoscienceAustralia / dea-cogger

Convert NetCDFs to Cloud Optimized GeoTIFFs
15 stars 4 forks source link

GDAL NetCDF Subdatasets #30

Open aclel opened 5 years ago

aclel commented 5 years ago

I'm Andrew from TERN. This is a cool tool. We have NetCDFs and Geotiffs that we want to convert to COG.

I've got a question regarding NetCDF Subdatasets. From my understanding, GDAL thinks that a NetCDF file has Subdatasets if there is more than one data variable, like temperature and rainfall in one file. If a file just has temperature, then it will not be a Subdataset, there will just be Bands.

Based on this line in the conversion code, does this mean that all of your NetCDF files have Subdatasets?

Some of our files just have one data variable, so GDAL doesn't detect them as Subdatasets. I tried converting them with this tool but it didn't do anything. If we end up using the tool I'm happy to do a PR, but I just wanted to get in touch first to check that I'm not misunderstanding Subdatsets.

See below for ncdump and gdalinfo from one of our NetCDF files:

ncdump Output:

netcdf FPARchl_EVI.A2014091.aust.v01.5600m.terra {
dimensions:
    time = UNLIMITED ; // (1 currently)
    latitude = 670 ;
    longitude = 813 ;
variables:
    double time(time) ;
        time:long_name = "time" ;
        time:standard_name = "time" ;
        time:units = "days since 1800-01-01 00:00:00.0" ;
        time:calendar = "gregorian" ;
        time:axis = "T" ;
    double latitude(latitude) ;
        latitude:long_name = "latitude" ;
        latitude:standard_name = "latitude" ;
        latitude:axis = "Y" ;
        latitude:units = "degrees_north" ;
    double longitude(longitude) ;
        longitude:long_name = "longitude" ;
        longitude:standard_name = "longitude" ;
        longitude:axis = "X" ;
        longitude:units = "degrees_east" ;
    float FPARchl(time, latitude, longitude) ;
        FPARchl:_FillValue = -3000.f ;
        FPARchl:long_name = "Ecosystem fraction of photosynthetic radiation absorbed by chlorophyll (fPARchl)" ;
        FPARchl:units = "unitless" ;
        FPARchl:grid_mapping = "crs" ;
    int crs ;
        crs:grid_mapping_name = "latitude_longitude" ;
        crs:longitude_of_prime_meridian = 0. ;
        crs:semi_major_axis = 6378137. ;
        crs:inverse_flattening = 298.257223563 ;
}

gdalinfo output:

Driver: netCDF/Network Common Data Format
Files: /input_rasters/chla_fraction/FPARchl_EVI.A2014091.aust.v01.5600m.terra.nc
Size is 813, 670
Coordinate System is:
GEOGCRS["unknown",
    DATUM["unnamed",
        ELLIPSOID["Spheroid",6378137,298.257223563,
            LENGTHUNIT["metre",1,
                ID["EPSG",9001]]]],
    PRIMEM["Greenwich",0,
        ANGLEUNIT["degree",0.0174532925199433,
            ID["EPSG",9122]]],
    CS[ellipsoidal,2],
        AXIS["latitude",north,
            ORDER[1],
            ANGLEUNIT["degree",0.0174532925199433,
                ID["EPSG",9122]]],
        AXIS["longitude",east,
            ORDER[2],
            ANGLEUNIT["degree",0.0174532925199433,
                ID["EPSG",9122]]]]
Data axis to CRS axis mapping: 2,1
Origin = (112.924999999999997,-10.074999999999999)
Pixel Size = (0.050000000000000,-0.050000000000000)
Metadata:
  crs#grid_mapping_name=latitude_longitude
  crs#inverse_flattening=298.257223563
  crs#longitude_of_prime_meridian=0
  crs#semi_major_axis=6378137
  time#axis=T
  time#calendar=gregorian
  time#long_name=time
  time#standard_name=time
  time#units=days since 1800-01-01 00:00:00.0
Corner Coordinates:
Upper Left  ( 112.9250000, -10.0750000) (112d55'30.00"E, 10d 4'30.00"S)
Lower Left  ( 112.9250000, -43.5750000) (112d55'30.00"E, 43d34'30.00"S)
Upper Right ( 153.5750000, -10.0750000) (153d34'30.00"E, 10d 4'30.00"S)
Lower Right ( 153.5750000, -43.5750000) (153d34'30.00"E, 43d34'30.00"S)
Center      ( 133.2500000, -26.8250000) (133d15' 0.00"E, 26d49'30.00"S)
Band 1 Block=813x670 Type=Float32, ColorInterp=Undefined
  NoData Value=-3000
  Unit Type: unitless
  Metadata:
    grid_mapping=crs
    long_name=Ecosystem fraction of photosynthetic radiation absorbed by chlorophyll (fPARchl)
    NETCDF_DIM_time=78252
    NETCDF_VARNAME=FPARchl
    units=unitless
    _FillValue=-3000