[gdal-dev] Successful warping of MODIS surface reflectance products from sinusoidal to HGRS87

nikos.alexandris at felis.uni-freiburg.de nikos.alexandris at felis.uni-freiburg.de
Wed Nov 28 07:37:13 EST 2007


I hope this time my mail comes through till the GDAL mail
-list ;-)

(Re-post!  Sorry, I was trying to post this through Nabble
since the
22th of November. Yet, it was not accepted all this days...
) 

Just FYI: 

Yoohooo! 

Many many thanks to all... !! 

The answer was in: http://trac.osgeo.org/gdal/ticket/1239  

--- 
[  $ gdalwarp -of HFA \ 

    -s_srs '+proj=sinu +R=6371007.181 +nadgrids=@null
+wktext' \ -t_srs 
TARGET-SRS \
'HDF4_EOS:EOS_GRID:"fpar8.hdf":MOD_Grid_MOD15A2:Fpar_1km'
\ 
fpar8.hfa 

        Note the key `+nadgrids=@null +wktext' options. In
TARGET-SRS,
` 
+ellps=sphere' becomes unnecessary (unless, of course, one
wants the 
dataset to be warped into a projection on a sphere.)  ] 
--- 

(Using Markus script ...slighlty modified, using 460x460
pixel
resolution for the output): 
--- 

#!/bin/sh 

#MODIS HDF/Sinusoidal to GeoTiff/HGRS87 
#Based on: 
#2005, Markus Neteler 
# warp MODIS HDF to Erdas/Img - LatLong/WGS84 

PROG="$0" 

if [ $# -lt 1 -o "$1" = "-h" -o "$1" = "--help" -o "$1" =
"-help" ] ; 
then 
 echo "Script to warp all layers of MODIS HDF to Erdas/Img
- 
LatLong/WGS84" 
 echo "Usage:" 
 echo "      $PROG M[OD|MYD]blablabla.hdf" 
 exit 1 
fi 

FILE=$1 
HDFlayerNAMES="`gdalinfo $FILE | grep SUBDATASET_ | grep
_NAME | cut 
-d'=' -f2`" 

#aarg! NDVI/EVI MOD13 contains spaces: 
HDFlayerNAMES_NOSPACES="`gdalinfo $FILE | grep SUBDATASET_
| grep _NAME 
| cut -d'=' -f2 | tr -s ' ' '|'`" 

#MODIS does not use the "Normal Sphere (r=6370997)"!!! 
# MODIS sphere, radius of 6371007.181 --> Instead use:
'+proj=sinu 
+R=6371007.181 +nadgrids=@null +wktext' 
#
http://edcdaac.usgs.gov/landdaac/tools/mrtswath/info/ReleaseNotes.pdf
 
# 
#GGRS87 (or HGRS87 or EGSA87) 
#<2100> +proj=tmerc +lat_0=0 +lon_0=24 +k=0.9996
+x_0=500000 +y_0=0 
+ellps=GRS80 +towgs84=-199.87,74.79,246.62,0,0,0,0 +units=m
+no_defs <> 

#loop over all layers: 
for i in ${HDFlayerNAMES_NOSPACES} ; do 
        #transform back: 
        INPUT="`echo ${i} | tr -s '|' ' '`" 
        NEWNAME="`echo ${i} | cut -d':' -f4,5 | tr ':' '_'
| tr -s '|' 
'_'`" 
        # apply GCPs 
        gdalwarp -s_srs '+proj=sinu +R=6371007.181
+nadgrids=@null 
+wktext' -t_srs '+init=epsg:2100' -tr 460 460 "${INPUT}" 
$NEWNAME.HGRS87.tif 
done 
--- 
-- 
Nikos Alexandris
.
Department of Remote Sensing & Landscape Information
Systems
Faculty of Forestry & Environmental Sciences,
Albert-Ludwigs-University Freiburg
.
Tel.  +49 (0) 761 203 3697 / Fax.  +49 (0) 761 203 3701 /
Skype: Nikos.Alexandris
.
Address: Tennenbacher str. 4, D-79106 Freiburg i. Br.,
Germany


More information about the gdal-dev mailing list