NDWI Scripting

I'm trying to apply an NDWI formula to the pair of loaded layers:

GLOBAL_MAPPER_SCRIPT VERSION=1.00 ENABLE_PROGRESS=YES
UNLOAD_ALL

DEFINE_VAR NAME="ESCENAS" VALUE="F:\Estudio Salar Maricunga\Pruebas Scripting\Escenas\"
DEFINE_VAR NAME="OUTPUT_DIR" VALUE="F:\Estudio Salar Maricunga\Pruebas Scripting\CLIP\"
DEFINE_VAR NAME="AOI" VALUE="F:\Estudio Salar Maricunga\Pruebas Scripting\AOI\AOI_Maricunga.shp"

DIR_LOOP_START DIRECTORY="%ESCENAS%" RECURSE_DIR=YES FILENAME_MASKS="*band2.tif *band4.tif"

   IMPORT FILENAME="%FNAME_W_DIR%" TYPE=GEOTIFF RASTER_TYPE="IMAGE"

   DEFINE_VAR NAME="B2" VALUE="%DIR%*band2.tif"
   DEFINE_VAR NAME="B4" VALUE="%DIR%*band4.tif"

   APPLY_FORMULA FILENAME="%B2%" FILENAME="%B4%" OUTPUT_BIT_DEPTH="32" FORMULA="(%B2%-             %B4%)/(%B2%+%B4%)" OUTPUT_GRID=YES

   EXPORT_ELEVATION FILENAME="%OUTPUT_DIR%%FNAME_WO_EXT%_ndwi.tif" TYPE=GEOTIFF COMPRESSION=NONE\
   POLYGON_CROP_FILE="%AOI%"

UNLOAD_ALL

DIR_LOOP_END

The part of applying the formula is not working. 
Any ideas?
Sign In or Register to comment.