#!/bin/bash # Script to resample NDVI product file to GeoTIFF output file in the IMAPP VA # Check input arguments if [ $# -ne 6 ]; then echo "# Usage: ndvi_to_geotiff.bash ndvi_file geo_file lat_min lon_min lat_max lon_max" echo "where" echo "ndvi_file is the full path and name of the MODIS NDVI HDF file (1000 m or 250 m)" echo "geo_file is the full path and name of the MODIS geolocation HDF file" echo "lat_min is the minimum latitude of the output region (degrees)" echo "lon_min is the minimum longitude of the output region (degrees)" echo "lat_max is the maximum latitude of the output region (degrees)" echo "lon_max is the maximum longitude of the output region (degrees)" exit 1 fi # Get arguments ndvi_file=$1 geo_file=$2 lat_min=$3 lon_min=$4 lat_max=$5 lon_max=$6 # Get file header (e.g., t1.11222.1621) header=$(basename $ndvi_file | cut -d. -f1-3) # Set up swath2grid export PATH=$DBVM_HOME/apps/dbge/bin:$PATH export MRTDATADIR=$DBVM_HOME/apps/dbge/bin/mrtdatadir # Create reprojected GeoTIFF images for NDVI and EVI swath2grid -if=$ndvi_file -gf=$geo_file -of=$header -off=GEOTIFF_FMT \ -oproj=GEO -osp=8 -kk=NN -oul="$lon_min","$lat_max" -olr="$lon_max","$lat_min"