Office Word | ||
---|---|---|
|
Instruction for running HEG on Command line mode (batch job) for a bunch of similar files
If you have lots of similar hdf files that need to be processed by HEG, you can use a script similar to the one given below (for example the one provided in HEG's bin directory) or just simply use HEG GUI. If you want to run a batch using HEG GUI please read section 8 of the GUI "Help".
Please follow the instructions below for Unix/Linux or Windows depending on your system.
Following is an example of such a template file created for a MODIS product:
NUM_RUNS = 1
BEGIN
INPUT_FILENAME = /home/abe/GIS_Proj/HEG_MODIS/2007/elt_season/input
OBJECT_NAME = MOD_Grid_Snow_500m
FIELD_NAME = Fractional_Snow_Cover
BAND_NUMBER = 1
SPATIAL_SUBSET_UL_CORNER = ( 90.0 -180.0 )
SPATIAL_SUBSET_LR_CORNER = ( -90.0 180.0)
RESAMPLING_TYPE = NN
OUTPUT_PROJECTION_TYPE = UTM
ELLIPSOID_CODE = WGS84
UTM_ZONE = 0
OUTPUT_PROJECTION_PARAMETERS = ( 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 )
OUTPUT_PIXEL_SIZE = 500.0
OUTPUT_FILENAME = /home/abe/GIS_Proj/HEG_MODIS/2007/out/melt_season/input_out.tif
OUTPUT_TYPE = GEO
END
8. Create a Shell Script file using following lines and make it executable type (e.g use "chmod 0755 myScript.sh"):
#! /bin/sh
# in this script it is assumed that HEG executables are in
# "/home/user/heg2.9/HEG/bin" directory, and that we are
# processing a file that contains GRIDS. For processing files
# that contain SWATH use "swtif" instead of "resample"
for i in `find .` ; do
hdffile=`file $i | awk '{print $2}'`
if [ "$hdffile" = "Hierarchical" ] ; then
sed 's/input/'$i'/' heg_template_unix.prm > $i.prm
/home/username/heg2.9/HEG/bin/resample -p $i.prm
fi
done
9. Before running the script set 3 environment variables (assuming that HEG is installed in /home/username/heg2.9/HEG/ ):
setenv MRTDATADIR /home/username/heg2.9/HEG/data
setenv PGSHOME /home/username/heg2.9/HEG/TOOLKIT_MTD
setenv HEGUSER ME
10. Now run the shell script for a HEG batch job!
Following is an example of such a template file created for a MODIS product:
NUM_RUNS = 1
BEGIN
INPUT_FILENAME = /home/abe/GIS_Proj/HEG_MODIS/2007/elt_season/input
OBJECT_NAME = MOD_Grid_Snow_500m
FIELD_NAME = Fractional_Snow_Cover
BAND_NUMBER = 1
SPATIAL_SUBSET_UL_CORNER = ( 90.0 -180.0 )
SPATIAL_SUBSET_LR_CORNER = ( -90.0 180.0)
RESAMPLING_TYPE = NN
OUTPUT_PROJECTION_TYPE = UTM
ELLIPSOID_CODE = WGS84
UTM_ZONE = 0
OUTPUT_PROJECTION_PARAMETERS = ( 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 )
OUTPUT_PIXEL_SIZE = 500.0
OUTPUT_FILENAME = /home/abe/GIS_Proj/HEG_MODIS/2007/out/melt_season/input_out.tif
OUTPUT_TYPE = GEO
END
Warning:
Please be aware that in windows if you edit your file with some editors such as wordpad the editor puts carriage return "^M" at the end of each line. This will prevent HEG from running and will cause error. Make sure that your editor will work like UNIX editors. If you have linux or cygwin, do editing there. Also the linux application "dos2unix" cleans up "^M" from a file.
...
View file | ||||
---|---|---|---|---|
|
Please also note that if you use MS wordpad for creating parameter file, you can use this executable on command line to get rid of LineFeed characters in your .prm file.
Here are the steps for using our Windows batch script:
...