I have a HDF file that I want to convert to tif or ENVI file.

I know that the +Proj of the original file is: "+proj=cea +lon_0=0 +lat_ts=30 +ellps=WGS84 +units=m"


  gdal_translate -of "ENVI" -a_srs "+proj=cea +lon_0=0 +lat_ts=30 +ellps=WGS84 +units=m" HDF5 file.h5  output.img

but I found that the projection was not defined but instead I got this:

     samples = 1000
     lines   = 500
     bands   = 1
     header offset = 0
     file type = ENVI Standard
     data type = 4
     interleave = bsq
     byte order = 0

My question how to deal with geo points?


Looking into your file, it has GCP points, and longitude and latitude subdatasets. But unfortunately the image is interrupted, and for the empty pixels, the coordinate values are also set to NODATA -9999. This makes the GCP interpolation impossible. A save way would be to save the subdataset to VRT format and eliminate the GCP with NODATA values, but these are too much for a manual adjustment.

So we take the bounding box information from the metadata (+/- 180°E +/- 85.044601°N) into a file named tbhbounds.txt:

-180.0 85.044601

convert them to EASE V2.0 and set the extent of the subdataset with the reprojected values. To kill the GCP entries I use a temporal XYZ format dataset:

cs2cs +init=epsg:4326 +to +proj=cea +lon_0=0 +lat_ts=30 +ellps=WGS84 +units=m tbhbounds.txt >ease.txt
gdal_translate -of "XYZ" HDF5:"SMAP.h5"://Soil_Moisture_Retrieval_Data/tb_h_corrected tbh.xyz
gdal_translate -of "ENVI" -a_ullr -17367530.45 7314541.22 17367530.45 -7314541.22 -a_srs "+proj=cea +lon_0=0 +lat_ts=30 +ellps=WGS84 +units=m"  -a_nodata -9999 tbh.xyz tbh3.envi

and the result looks like this:

enter image description here

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.