[gdal-dev] Help working with hdf5 images

Stephen Woodbridge woodbri at swoodbridge.com
Sun Feb 19 07:15:20 PST 2017


Hi all,

I'm trying to create GTiff files from IMARS Modis hdf5 images. I did 
something like this about 3-4 years ago when they were using hdf4 
datasets but things have changed since then. So I have two questions:

1. How do I extract the sst data (subdataset 3) into a GTiff and create 
a mask band from the sst_count (subdataset 4) which has value 0 or 1, 
where 1 is valid sst data?

2. The data is in Equidistant_Cylindrical / World Geodetic System 1984 
which does not seem to be represent able as a proj4 format and I need to 
reproject into EPSG:4326

In the past I used the both the gcoos and seacoos images for a given 
time slot like:

gdal_translate -of GTiff -ot Int16 -a_srs EPSG:4326  -a_ullr $ullr 
-scale 0 50 0 10000 $filename $tmpfile

where $ullr is correct for the image and then used gdal_merge to combine 
the two images using:

gdal_merge -of GTiff -co TILED=YES -ot Int16 -o $target <list of input 
files>

But this does not work because when I merge the images they are offset 
and I need to apply the mask so the images are transparent where there 
is no data.

I guess this is my week to ask lots of gdal related question.

Thanks,
   -Steve

ftp://imars.marine.usf.edu/modis/imars/final/pass/1km/sst/gcoos/2017.02/aqua.20170217.0645.gcoos.sst.h5

----------------------------------------------- hdf5 file --------------
$ gdalinfo aqua.20170217.0645.gcoos.sst.h5
Driver: HDF5/Hierarchical Data Format Release 5
Files: aqua.20170217.0645.gcoos.sst.h5
Size is 512, 512
Coordinate System is `'
Metadata:
   bands_l2_flags_CLASS=IMAGE
   bands_l2_flags_count_CLASS=IMAGE
   bands_l2_flags_count_description=Count of l2_flags
   bands_l2_flags_count_IMAGE_VERSION=1.2
   bands_l2_flags_count_log10_scaled=false
   bands_l2_flags_count_raster_height=1447
   bands_l2_flags_count_raster_width=2115
   bands_l2_flags_count_scaling_factor=1
   bands_l2_flags_count_scaling_offset=0
   bands_l2_flags_description=l2_flags
   bands_l2_flags_IMAGE_VERSION=1.2
   bands_l2_flags_log10_scaled=false
   bands_l2_flags_raster_height=1447
   bands_l2_flags_raster_width=2115
   bands_l2_flags_scaling_factor=1
   bands_l2_flags_scaling_offset=0
   bands_sst_CLASS=IMAGE
   bands_sst_count_CLASS=IMAGE
   bands_sst_count_description=Count of sst
   bands_sst_count_IMAGE_VERSION=1.2
   bands_sst_count_log10_scaled=false
   bands_sst_count_raster_height=1447
   bands_sst_count_raster_width=2115
   bands_sst_count_scaling_factor=1
   bands_sst_count_scaling_offset=0
   bands_sst_description=sst
   bands_sst_IMAGE_VERSION=1.2
   bands_sst_log10_scaled=false
   bands_sst_raster_height=1447
   bands_sst_raster_width=2115
   bands_sst_scaling_factor=1
   bands_sst_scaling_offset=0
   metadata_Processing_Graph_node.0_authors=Marco Peters, Ralf Quast, 
Marco Zühlk
   metadata_Processing_Graph_node.0_copyright=(c) 2009 by Brockmann Consult
   metadata_Processing_Graph_node.0_id=Mosaic$15A4BDE1324
   metadata_Processing_Graph_node.0_moduleName=beam-gpf
   metadata_Processing_Graph_node.0_moduleVersion=5.0.5
   metadata_Processing_Graph_node.0_operator=Mosaic
   metadata_Processing_Graph_node.0_parameters_combine=OR
 
metadata_Processing_Graph_node.0_parameters_crs=PROJCS["Equidistant_Cylindrical 
/ World Geodetic System 1984",
       GEOGCS["World Geodetic System 1984",
         DATUM["World Geodetic System 1984",
           SPHEROID["WGS 84", 6378137.0, 298.257223563, 
AUTHORITY["EPSG","7030"]],
           AUTHORITY["EPSG","6326"]],
         PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],
         UNIT["degree", 0.017453292519943295],
         AXIS["Geodetic longitude", EAST],
         AXIS["Geodetic latitude", NORTH]],
       PROJECTION["Equidistant_Cylindrical"],
       PARAMETER["central_meridian", 0.0],
       PARAMETER["latitude_of_origin", 0.0],
       PARAMETER["standard_parallel_1", 0.0],
       PARAMETER["false_easting", 0.0],
       PARAMETER["false_northing", 0.0],
       UNIT["m", 1.0],
       AXIS["Easting", EAST],
       AXIS["Northing", NORTH]]
   metadata_Processing_Graph_node.0_parameters_eastBound=-79.0
   metadata_Processing_Graph_node.0_parameters_northBound=31.0
   metadata_Processing_Graph_node.0_parameters_orthorectify=false
   metadata_Processing_Graph_node.0_parameters_pixelSizeX=1000.0
   metadata_Processing_Graph_node.0_parameters_pixelSizeY=1000.0
   metadata_Processing_Graph_node.0_parameters_resampling=Nearest
   metadata_Processing_Graph_node.0_parameters_southBound=18.0
 
metadata_Processing_Graph_node.0_parameters_variables_variable.0_expression=sst
   metadata_Processing_Graph_node.0_parameters_variables_variable.0_name=sst
 
metadata_Processing_Graph_node.0_parameters_variables_variable.1_expression=l2_flags
 
metadata_Processing_Graph_node.0_parameters_variables_variable.1_name=l2_flags
   metadata_Processing_Graph_node.0_parameters_westBound=-98.0
   metadata_Processing_Graph_node.0_processingTime=2017-02-17T11:38:49.524Z
   metadata_Processing_Graph_node.0_purpose=Creates a mosaic out of a 
set of source products.
 
metadata_Processing_Graph_node.0_sources_sourceProduct.1=file:/home/ipopp/temp/aqua.SST.FILTERED.17048065000_mapped.dim
 
metadata_Processing_Graph_node.0_sources_sourceProduct.2=file:/home/ipopp/temp/aqua.SST.FILTERED.17048065500_mapped.dim
   metadata_Processing_Graph_node.0_version=1.0
Subdatasets:
   SUBDATASET_1_NAME=HDF5:"aqua.20170217.0645.gcoos.sst.h5"://bands/l2_flags
   SUBDATASET_1_DESC=[1447x2115] //bands/l2_flags (32-bit floating-point)
 
SUBDATASET_2_NAME=HDF5:"aqua.20170217.0645.gcoos.sst.h5"://bands/l2_flags_count
   SUBDATASET_2_DESC=[1447x2115] //bands/l2_flags_count (32-bit integer)
   SUBDATASET_3_NAME=HDF5:"aqua.20170217.0645.gcoos.sst.h5"://bands/sst
   SUBDATASET_3_DESC=[1447x2115] //bands/sst (32-bit floating-point)
 
SUBDATASET_4_NAME=HDF5:"aqua.20170217.0645.gcoos.sst.h5"://bands/sst_count
   SUBDATASET_4_DESC=[1447x2115] //bands/sst_count (32-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)
Center      (  256.0,  256.0)

-------------- HDF5:"aqua.20170217.0645.gcoos.sst.h5"://bands/sst -----
$ gdalinfo HDF5:"aqua.20170217.0645.gcoos.sst.h5"://bands/sst
Driver: HDF5Image/HDF5 Dataset
Files: aqua.20170217.0645.gcoos.sst.h5
        aqua.20170217.0645.gcoos.sst.h5.aux.xml
Size is 2115, 1447
Coordinate System is `'
Metadata:
   metadata_Processing_Graph_node.0_authors=Marco Peters, Ralf Quast, 
Marco Zühlk
   metadata_Processing_Graph_node.0_copyright=(c) 2009 by Brockmann Consult
   metadata_Processing_Graph_node.0_id=Mosaic$15A4BDE1324
   metadata_Processing_Graph_node.0_moduleName=beam-gpf
   metadata_Processing_Graph_node.0_moduleVersion=5.0.5
   metadata_Processing_Graph_node.0_operator=Mosaic
   metadata_Processing_Graph_node.0_parameters_combine=OR
 
metadata_Processing_Graph_node.0_parameters_crs=PROJCS["Equidistant_Cylindrical 
/ World Geodetic System 1984",
       GEOGCS["World Geodetic System 1984",
         DATUM["World Geodetic System 1984",
           SPHEROID["WGS 84", 6378137.0, 298.257223563, 
AUTHORITY["EPSG","7030"]],
           AUTHORITY["EPSG","6326"]],
         PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],
         UNIT["degree", 0.017453292519943295],
         AXIS["Geodetic longitude", EAST],
         AXIS["Geodetic latitude", NORTH]],
       PROJECTION["Equidistant_Cylindrical"],
       PARAMETER["central_meridian", 0.0],
       PARAMETER["latitude_of_origin", 0.0],
       PARAMETER["standard_parallel_1", 0.0],
       PARAMETER["false_easting", 0.0],
       PARAMETER["false_northing", 0.0],
       UNIT["m", 1.0],
       AXIS["Easting", EAST],
       AXIS["Northing", NORTH]]
   metadata_Processing_Graph_node.0_parameters_eastBound=-79.0
   metadata_Processing_Graph_node.0_parameters_northBound=31.0
   metadata_Processing_Graph_node.0_parameters_orthorectify=false
   metadata_Processing_Graph_node.0_parameters_pixelSizeX=1000.0
   metadata_Processing_Graph_node.0_parameters_pixelSizeY=1000.0
   metadata_Processing_Graph_node.0_parameters_resampling=Nearest
   metadata_Processing_Graph_node.0_parameters_southBound=18.0
 
metadata_Processing_Graph_node.0_parameters_variables_variable.0_expression=sst
   metadata_Processing_Graph_node.0_parameters_variables_variable.0_name=sst
 
metadata_Processing_Graph_node.0_parameters_variables_variable.1_expression=l2_flags
 
metadata_Processing_Graph_node.0_parameters_variables_variable.1_name=l2_flags
   metadata_Processing_Graph_node.0_parameters_westBound=-98.0
   metadata_Processing_Graph_node.0_processingTime=2017-02-17T11:38:49.524Z
   metadata_Processing_Graph_node.0_purpose=Creates a mosaic out of a 
set of source products.
 
metadata_Processing_Graph_node.0_sources_sourceProduct.1=file:/home/ipopp/temp/aqua.SST.FILTERED.17048065000_mapped.dim
 
metadata_Processing_Graph_node.0_sources_sourceProduct.2=file:/home/ipopp/temp/aqua.SST.FILTERED.17048065500_mapped.dim
   metadata_Processing_Graph_node.0_version=1.0
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0, 1447.0)
Upper Right ( 2115.0,    0.0)
Lower Right ( 2115.0, 1447.0)
Center      ( 1057.5,  723.5)
Band 1 Block=2115x1 Type=Float32, ColorInterp=Undefined
   Min=0.000 Max=27.285
   Minimum=0.000, Maximum=27.285, Mean=1.329, StdDev=5.395
   Metadata:
     bands_sst_CLASS=IMAGE
     bands_sst_description=sst
     bands_sst_IMAGE_VERSION=1.2
     bands_sst_log10_scaled=false
     bands_sst_raster_height=1447
     bands_sst_raster_width=2115
     bands_sst_scaling_factor=1
     bands_sst_scaling_offset=0
     STATISTICS_MAXIMUM=27.284999847412
     STATISTICS_MEAN=1.3292428022154
     STATISTICS_MINIMUM=0
     STATISTICS_STDDEV=5.3949041458808

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



More information about the gdal-dev mailing list