<div dir="ltr">Also asked here: <a href="http://gis.stackexchange.com/questions/170882/how-can-a-make-a-netcdf-with-subgroups-smaller">http://gis.stackexchange.com/questions/170882/how-can-a-make-a-netcdf-with-subgroups-smaller</a><br>
<div><br></div><div>Is there an easy way to make a netcdf with subdatasets but shrink it without resorting to C or Fortan?</div><div><br></div><div><div>I'm trying to write a test for code that works with hycom netcdf global ocean circulation data. The source file 2 subdatasets:</div><div><br></div><div>gdalinfo <a href="http://hycom_glb_911_2015110200_t000_uv3z.nc">hycom_glb_911_2015110200_t000_uv3z.nc</a> | grep _NAME</div><div>  SUBDATASET_1_NAME=NETCDF:"<a href="http://hycom_glb_911_2015110200_t000_uv3z.nc">hycom_glb_911_2015110200_t000_uv3z.nc</a>":water_u</div><div>  SUBDATASET_2_NAME=NETCDF:"<a href="http://hycom_glb_911_2015110200_t000_uv3z.nc">hycom_glb_911_2015110200_t000_uv3z.nc</a>":water_v</div><div>With 40 depth bands:</div><div><br></div><div>gdalinfo NETCDF:hycom_glb_911_2015110200_t000_uv3z.nc:water_u | grep '^Band' | head -3</div><div>Band 1 Block=4500x1 Type=Int16, ColorInterp=Undefined</div><div>Band 2 Block=4500x1 Type=Int16, ColorInterp=Undefined</div><div>Band 3 Block=4500x1 Type=Int16, ColorInterp=Undefined</div><div>I've got some code written the does things like calculate the speed in m/s from the UV and creates a geotiff, etc. The original files are much too large for using in unittests. Is there an easy way with gdal, nco or ? to keep the structure and metadata, but create a much smaller file? I'm open to dropping all but the first two bands and writing a constant value into each band + turning on deflate compression.</div><div><br></div><div>Trying with GDAL:</div><div><br></div><div>gdal_translate --version  # At head -> r31584</div><div>GDAL 2.1.0dev, released 2015/99/99</div><div><br></div><div>gdal_translate <a href="http://hycom_glb_911_2015110200_t000_uv3z.nc">hycom_glb_911_2015110200_t000_uv3z.nc</a> <a href="http://hycom_glb_911_2015110200_t000_uv3z-try2.nc">hycom_glb_911_2015110200_t000_uv3z-try2.nc</a> -of netcdf -co compress=deflate</div><div>Input file contains subdatasets. Please, select one of them for reading.</div><div>The originals are quite a bit large for tests:</div><div><br></div><div>ls -lh <a href="http://hycom_glb_911_2015110200_t000_uv3z.nc">hycom_glb_911_2015110200_t000_uv3z.nc</a></div><div>-rw-r----- 1 schwehr group 1.4G Nov 19 09:13 <a href="http://hycom_glb_911_2015110200_t000_uv3z.nc">hycom_glb_911_2015110200_t000_uv3z.nc</a></div></div><div><br></div><div>Thanks,</div><div>-kurt</div></div>