On 2/19/2017 10:15 AM, Stephen Woodbridge wrote:
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?
OK, I think I have figured out part of this:
gdal_translate -of GTiff -a_srs EPSG:4326 -a_ullr $ullr -sds infile.h5
tempfile
echo tempfile3 > temp.in # add sds 3 the sst data
echo tempfile4 >> temp.in # add sds 4 the stt_count data
# stack the bands
gdalbuildvrt -separate -input_file_list temp.in tempfile.vrt
create a tif with mask from the stacked bands
gdal_translate -b 1 -mask 2 -co TILED=YES -ot Int16 -scale 0 50 0 10000
tempfile.vrt tempfile.tif
# tile areas for a given time slot
gdal_merge -of GTiff -co TILED=YES -ot Int16 -o target.tif <list of files>
# manually create a vrt file with color table for target.tif (target.vrt)
# and for debug visualization
gdal_translate -of PNG -scale 0 10000 target.vrt target.png
This still has problems with the adjacent overlapping areas not being
georeferenced correctly and the mask is not getting applied during the
merge as can be seen here:
http://imaptools.com:8080/dl/IMARS_SST-201702190815.png
You can see that the lower left image has another layered on top of it
shifted north and east and then image has a square corner of black
blotting out part of the lower left image. The IMARS data has gcoos and
seacoos areas that overlap but for the same time slot the images should
be able to be merged.
-Steve
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
_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev