1

I am very new in this. My goal is to convert 1 subband from .nc files (which I have several thousand if it matters) stored in longlat projection into .tif files in EASE 2.0 projection.

I do that in 2 steps:

1. gdal_translate from .nc to .tif like so:

for file in *.nc
do
gdal_translate -of GTiff NETCDF:"$file":vod   ${file%.*}.tif
done

At this stage I get a warning:

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute

which I have no idea what to do about (I googled and similar warnings seem to come from not specifying the sub band, but I do that - :vod). Also, these .nc files seem to have this warning initially in the info (see below).

2. reproject .tif to EASE 2.0, which is EPSG:6933, which is not defined in gdal implicitly, so I use the projection parameters from the EPSG website

for file in *.tif
do 
gdalwarp -s_srs "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +to wgs84=0,0,0" -t_srs "+proj=cea +lon_0=0 +lat_ts=30 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs" -srcnodata -32768 -r bilinear "$file" "tr$file"
done

which seems to go smoothly.

Only when I try to open the resulting .tif in python I get the following error:

from PIL import Image

m = Image.open('myfile.tif')
IOError: cannot identify image file 'myfile.tif'

So, my questions are:

1. Is the warning in step 1 the source of the problem?

2. Is the problem with python not opening the file has nothing to do with reprojections?

Some additional info from gdalinfo:

Initial file

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute
Driver: netCDF/Network Common Data Format
Files: vodca_v01-0_C-band_2018-12-29.nc
Size is 512, 512
Coordinate System is `'
Metadata:
  NC_GLOBAL#_NCProperties=version=1|netcdflibversion=4.4.1.1|hdf5libversion=1.10.2
  NC_GLOBAL#band=C-band (6.8 GHz - 7.3 GHZ)
  NC_GLOBAL#calendar=standard
  NC_GLOBAL#contact=vodca@geo.tuwien.ac.at
  NC_GLOBAL#conventions=CF-1.6
  NC_GLOBAL#creatorname=Department of Geodesy and Geoinformation, Technical University of Vienna
  NC_GLOBAL#creatorurl=http://rs.geo.tuwien.ac.at
  NC_GLOBAL#DOI=10.5281/zenodo.2575599
  NC_GLOBAL#geospatiallatmax=90.0
  NC_GLOBAL#geospatiallatmin=-90.0
  NC_GLOBAL#geospatiallatresolution=0.25 degree
  NC_GLOBAL#geospatiallatunits=degrees_north
  NC_GLOBAL#geospatiallonmax=180.0
  NC_GLOBAL#geospatiallonmin=-180.0
  NC_GLOBAL#geospatiallonresolution=0.25 degree
  NC_GLOBAL#geospatiallonunits=degrees_east
  NC_GLOBAL#geospatialverticalmax=0.0
  NC_GLOBAL#geospatialverticalmin=0.0
  NC_GLOBAL#insitute=Technical University of Vienna (AUT); Transmissivity B.V. / VanderSat B.V. Noordwijk (NL)
  NC_GLOBAL#license=Creative Commons Attribution 4.0 International
  NC_GLOBAL#namingauthority=TU Wien
  NC_GLOBAL#product_version=01.0
  NC_GLOBAL#productname:=VODCA
  NC_GLOBAL#sensors=SSMI, TMI, AMSR-E, WindSat, AMSR2
  NC_GLOBAL#spatialresolution=25 km
  NC_GLOBAL#standard_name_vocabulary=NetCDF Climate and Forecast (CF) Metadata Convention
  NC_GLOBAL#timecoverageenddate=2018-12-31T23:59:59
  NC_GLOBAL#timecoverageresolution=P1D
  NC_GLOBAL#timecoveragestartdate=2002-06-19T00:00:00
  NC_GLOBAL#title=Global long-term Vegetation optical depth climate-data aggregate VODCA
Subdatasets:
  SUBDATASET_1_NAME=NETCDF:"vodca_v01-0_C-band_2018-12-29.nc":vod
  SUBDATASET_1_DESC=[1x720x1440] vod (64-bit floating-point)
  SUBDATASET_2_NAME=NETCDF:"vodca_v01-0_C-band_2018-12-29.nc":sensor_flag
  SUBDATASET_2_DESC=[1x720x1440] sensor_flag (64-bit floating-point)
  SUBDATASET_3_NAME=NETCDF:"vodca_v01-0_C-band_2018-12-29.nc":processing_flag
  SUBDATASET_3_DESC=[1x720x1440] processing_flag (64-bit floating-point)
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  512.0)
Upper Right (  512.0,    0.0)
Lower Right (  512.0,  512.0)
Center      (  256.0,  256.0)

Tif file after step 1

Driver: GTiff/GeoTIFF
Files: vodca_v01-0_C-band_2018-12-30.tif
Size is 1440, 720
Coordinate System is `'
Origin = (-180.000000000000000,90.000000000000000)
Pixel Size = (0.250000000000000,-0.250000000000000)
Metadata:
  lat#standard_name=latitude
  lat#units=degrees_north
  lat#valid_range={-90,90}
  lon#standard_name=longitude
  lon#units=degrees_east
  lon#valid_range={-180,180}
  NC_GLOBAL#_NCProperties=version=1|netcdflibversion=4.4.1.1|hdf5libversion=1.10.2
  NC_GLOBAL#band=C-band (6.8 GHz - 7.3 GHZ)
  NC_GLOBAL#calendar=standard
  NC_GLOBAL#contact=vodca@geo.tuwien.ac.at
  NC_GLOBAL#conventions=CF-1.6
  NC_GLOBAL#creatorname=Department of Geodesy and Geoinformation, Technical University of Vienna
  NC_GLOBAL#creatorurl=http://rs.geo.tuwien.ac.at
  NC_GLOBAL#DOI=10.5281/zenodo.2575599
  NC_GLOBAL#geospatiallatmax=90.0
  NC_GLOBAL#geospatiallatmin=-90.0
  NC_GLOBAL#geospatiallatresolution=0.25 degree
  NC_GLOBAL#geospatiallatunits=degrees_north
  NC_GLOBAL#geospatiallonmax=180.0
  NC_GLOBAL#geospatiallonmin=-180.0
  NC_GLOBAL#geospatiallonresolution=0.25 degree
  NC_GLOBAL#geospatiallonunits=degrees_east
  NC_GLOBAL#geospatialverticalmax=0.0
  NC_GLOBAL#geospatialverticalmin=0.0
  NC_GLOBAL#insitute=Technical University of Vienna (AUT); Transmissivity B.V. / VanderSat B.V. Noordwijk (NL)
  NC_GLOBAL#license=Creative Commons Attribution 4.0 International
  NC_GLOBAL#namingauthority=TU Wien
  NC_GLOBAL#product_version=01.0
  NC_GLOBAL#productname==VODCA
  NC_GLOBAL#sensors=SSMI, TMI, AMSR-E, WindSat, AMSR2
  NC_GLOBAL#spatialresolution=25 km
  NC_GLOBAL#standard_name_vocabulary=NetCDF Climate and Forecast (CF) Metadata Convention
  NC_GLOBAL#timecoverageenddate=2018-12-31T23:59:59
  NC_GLOBAL#timecoverageresolution=P1D
  NC_GLOBAL#timecoveragestartdate=2002-06-19T00:00:00
  NC_GLOBAL#title=Global long-term Vegetation optical depth climate-data aggregate VODCA
  NETCDF_DIM_EXTRA={time}
  NETCDF_DIM_time_DEF={1,6}
  NETCDF_DIM_time_VALUES=17895
  time#calendar=standard
  time#long_name=time
  time#units=days since 1970-1-1 0:0:0
  vod#_FillValue=-999999
  vod#long_name=Vegetation optical depth
  vod#units=unitless
  vod#valid_range={0,inf}
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (-180.0000000,  90.0000000) 
Lower Left  (-180.0000000, -90.0000000) 
Upper Right ( 180.0000000,  90.0000000) 
Lower Right ( 180.0000000, -90.0000000) 
Center      (   0.0000000,   0.0000000) 
Band 1 Block=1440x1 Type=Float64, ColorInterp=Gray
  NoData Value=-999999
  Metadata:
    _FillValue=-999999
    long_name=Vegetation optical depth
    NETCDF_DIM_time=17895
    NETCDF_VARNAME=vod
    units=unitless
    valid_range={0,inf}

Final tif

Size is 1483, 627
Coordinate System is:
PROJCS["unnamed",
    GEOGCS["WGS 84",
        DATUM["unknown",
            SPHEROID["WGS84",6378137,298.257223563]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433]],
    PROJECTION["Cylindrical_Equal_Area"],
    PARAMETER["standard_parallel_1",30],
    PARAMETER["central_meridian",0],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]]]
Origin = (-17367530.445161376148462,7342230.136498682200909)
Pixel Size = (23407.953829473473888,-23423.748670114142442)
Metadata:
  AREA_OR_POINT=Area
  lat#standard_name=latitude
  lat#units=degrees_north
  lat#valid_range={-90,90}
  lon#standard_name=longitude
  lon#units=degrees_east
  lon#valid_range={-180,180}
  NC_GLOBAL#_NCProperties=version=1|netcdflibversion=4.4.1.1|hdf5libversion=1.10.2
  NC_GLOBAL#band=C-band (6.8 GHz - 7.3 GHZ)
  NC_GLOBAL#calendar=standard
  NC_GLOBAL#contact=vodca@geo.tuwien.ac.at
  NC_GLOBAL#conventions=CF-1.6
  NC_GLOBAL#creatorname=Department of Geodesy and Geoinformation, Technical University of Vienna
  NC_GLOBAL#creatorurl=http://rs.geo.tuwien.ac.at
  NC_GLOBAL#DOI=10.5281/zenodo.2575599
  NC_GLOBAL#geospatiallatmax=90.0
  NC_GLOBAL#geospatiallatmin=-90.0
  NC_GLOBAL#geospatiallatresolution=0.25 degree
  NC_GLOBAL#geospatiallatunits=degrees_north
  NC_GLOBAL#geospatiallonmax=180.0
  NC_GLOBAL#geospatiallonmin=-180.0
  NC_GLOBAL#geospatiallonresolution=0.25 degree
  NC_GLOBAL#geospatiallonunits=degrees_east
  NC_GLOBAL#geospatialverticalmax=0.0
  NC_GLOBAL#geospatialverticalmin=0.0
  NC_GLOBAL#insitute=Technical University of Vienna (AUT); Transmissivity B.V. / VanderSat B.V. Noordwijk (NL)
  NC_GLOBAL#license=Creative Commons Attribution 4.0 International
  NC_GLOBAL#namingauthority=TU Wien
  NC_GLOBAL#product_version=01.0
  NC_GLOBAL#productname==VODCA
  NC_GLOBAL#sensors=SSMI, TMI, AMSR-E, WindSat, AMSR2
  NC_GLOBAL#spatialresolution=25 km
  NC_GLOBAL#standard_name_vocabulary=NetCDF Climate and Forecast (CF) Metadata Convention
  NC_GLOBAL#timecoverageenddate=2018-12-31T23:59:59
  NC_GLOBAL#timecoverageresolution=P1D
  NC_GLOBAL#timecoveragestartdate=2002-06-19T00:00:00
  NC_GLOBAL#title=Global long-term Vegetation optical depth climate-data aggregate VODCA
  NETCDF_DIM_EXTRA={time}
  NETCDF_DIM_time_DEF={1,6}
  NETCDF_DIM_time_VALUES=17894
  time#calendar=standard
  time#long_name=time
  time#units=days since 1970-1-1 0:0:0
  vod#_FillValue=-999999
  vod#long_name=Vegetation optical depth
  vod#units=unitless
  vod#valid_range={0,inf}
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (-17367530.445, 7342230.136) (180d 0' 0.00"W, 90d 0' 0.00"N)
Lower Left  (-17367530.445,-7344460.280) (180d 0' 0.00"W,-2147483648d-2147483648'  nan"N)
Upper Right (17346465.084, 7342230.136) (179d46'54.03"E, 90d 0' 0.00"N)
Lower Right (17346465.084,-7344460.280) (179d46'54.03"E,-2147483648d-2147483648'  nan"N)
Center      (  -10532.681,   -1115.072) (  0d 6'32.98"W,  0d 0'31.47"S)
Band 1 Block=1483x1 Type=Float64, ColorInterp=Gray
  NoData Value=-32768
  Metadata:
    _FillValue=-999999
    long_name=Vegetation optical depth
    NETCDF_DIM_time=17894
    NETCDF_VARNAME=vod
    units=unitless
    valid_range={0,inf}
0

Perhaps a few answers...

  1. This is just a warning. Names of objects in netCDF are case sensitive, and conventions is ignored, thus it is assumed that the document does not use CF Conventions and Metadata. The recognized global attribute to use is Conventions (ref). You can use NCO's ncrename utility to rename the attribute:

    ncrename -a conventions,Conventions vodca_v01-0_C-band_2018-12-29.nc
    

    however, it may not solve any of the issues. Also, why are you using gdal_translate when you can just use gdalwarp?

  2. The PROJ string in -s_srs has +to, which normally describes a conversion from one SRS to another. I suggest removing +to wgs84=0,0,0. As above, I suggest using the netCDF subdataset (NETCDF:"$file":vod) as the source input, then the same reprojected output GeoTIFF. Without seeing the output, the file looks fine according to gdalinfo. Does PIL work for float64 types. Try either rasterio or GDAL to read the raster data instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.