1

I am trying to pull layers from the glocal ocean circulation model Hycom. Before I go writing code to try to do this, is there a way to pull a single z depth as a geotiff?

e.g. I have hycom_glb_911_2015093000_t000_uv3z.nc. gdalinfo (gdal pre 2.1.0) reports:

gdalinfo hycom_glb_911_2015093000_t000_uv3z.nc

Driver: netCDF/Network Common Data Format
Files: hycom_glb_911_2015093000_t000_uv3z.nc
Size is 512, 512
Coordinate System is `'
Metadata:
  NC_GLOBAL#classification_authority=not applicable
  NC_GLOBAL#classification_level=UNCLASSIFIED
  NC_GLOBAL#Conventions=CF-1.0 NAVO_netcdf_v1.0
  NC_GLOBAL#distribution_statement=Approved for public release. Distribution unlimited.
  NC_GLOBAL#downgrade_date=not applicable
  NC_GLOBAL#field_type=instantaneous
  NC_GLOBAL#history=archv2ncdf3z
  NC_GLOBAL#institution=Naval Oceanographic Office
  NC_GLOBAL#source=HYCOM archive file
Subdatasets:
  SUBDATASET_1_NAME=NETCDF:"hycom_glb_911_2015093000_t000_uv3z.nc":water_u
  SUBDATASET_1_DESC=[1x40x2001x4500] eastward_sea_water_velocity (16-bit integer)
  SUBDATASET_2_NAME=NETCDF:"hycom_glb_911_2015093000_t000_uv3z.nc":water_v
  SUBDATASET_2_DESC=[1x40x2001x4500] northward_sea_water_velocity (16-bit integer)
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)

ncdump:

ncdump -h hycom_glb_911_2015093000_t000_uv3z.nc 
netcdf hycom_glb_911_2015093000_t000_uv3z {
dimensions:
    lat = 2001 ;
    lon = 4500 ;
    depth = 40 ;
    time = UNLIMITED ; // (1 currently)
variables:
    double time(time) ;
        time:long_name = "Valid Time" ;
        time:units = "hours since 2000-01-01 00:00:00" ;
        time:time_origin = "2000-01-01 00:00:00" ;
        time:calendar = "gregorian" ;
        time:axis = "T" ;
        time:NAVO_code = 13 ;
    double tau(time) ;
        tau:long_name = "Tau" ;
        tau:units = "hours since analysis" ;
        tau:time_origin = "2015-09-30 00:00:00" ;
        tau:NAVO_code = 56 ;
    double depth(depth) ;
        depth:long_name = "Depth" ;
        depth:standard_name = "depth" ;
        depth:units = "m" ;
        depth:positive = "down" ;
        depth:axis = "Z" ;
        depth:NAVO_code = 5 ;
    double lat(lat) ;
        lat:long_name = "Latitude" ;
        lat:standard_name = "latitude" ;
        lat:units = "degrees_north" ;
        lat:point_spacing = "even" ;
        lat:axis = "Y" ;
        lat:NAVO_code = 1 ;
    double lon(lon) ;
        lon:long_name = "Longitude" ;
        lon:standard_name = "longitude" ;
        lon:units = "degrees_east" ;
        lon:modulo = "360 degrees" ;
        lon:axis = "X" ;
        lon:NAVO_code = 2 ;
    short water_u(time, depth, lat, lon) ;
        water_u:long_name = "Eastward Water Velocity" ;
        water_u:standard_name = "eastward_sea_water_velocity" ;
        water_u:units = "m/s" ;
        water_u:_FillValue = -30000s ;
        water_u:missing_value = -30000s ;
        water_u:scale_factor = 0.001f ;
        water_u:add_offset = 0.f ;
        water_u:NAVO_code = 17 ;
    short water_v(time, depth, lat, lon) ;
        water_v:long_name = "Northward Water Velocity" ;
        water_v:standard_name = "northward_sea_water_velocity" ;
        water_v:units = "m/s" ;
        water_v:_FillValue = -30000s ;
        water_v:missing_value = -30000s ;
        water_v:scale_factor = 0.001f ;
        water_v:add_offset = 0.f ;
        water_v:NAVO_code = 18 ;

// global attributes:
        :classification_level = "UNCLASSIFIED" ;
        :distribution_statement = "Approved for public release. Distribution unlimited." ;
        :downgrade_date = "not applicable" ;
        :classification_authority = "not applicable" ;
        :institution = "Naval Oceanographic Office" ;
        :source = "HYCOM archive file" ;
        :history = "archv2ncdf3z" ;
        :field_type = "instantaneous" ;
        :Conventions = "CF-1.0 NAVO_netcdf_v1.0" ;
1

1 Answer 1

2

You can use gdal_translate (NetCDF documentation) for this. I didn't download your dataset but I tested on a sample. The trick is to type in the name f the resource exactly as it's listed in gdalinfo. For example:

gdal_translate NETCDF:"hycom_glb_911_2015093000_t000_uv3z.nc":water_v water_v.tif

This gives you a GeoTiff with the water_v subdataset.

1
  • Pulling a single band: gdal_translate -b 1 NETCDF:hycom_glb_911_2015093000_t000_uv3z.nc:water_u hycom_glb_911_2015093000_t000_uv3z_water_u_b1.tif Oct 22, 2015 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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