Specify "NDVI Shader" for output file
rdptwh
Global Mapper User
Hi,
I need to create NDVI layers from a large number of NIR NAIP images. I've written a script that correctly creates a NDVI layer for each NAIP quarter quad, but they are gray scale and I can't for the life of me figure out how to to export them with the NDVI shader.
I can load the files back into GM and apply the shader, but ...
Any Suggestions?
My script follows
--bob
GLOBAL_MAPPER_SCRIPT VERSION=1.00
UNLOAD_ALL
// Loop over all .tif files in a folder and convert them
DIR_LOOP_START DIRECTORY="C:\Users\rdp\NDVI\test\" FILENAME_MASKS="*.tif" TYPE="GEOTIFF" \
LABEL_FIELD_FORCE_OVERWRITE="NO" LABEL_FORMAT_NUMBERS="YES" LABEL_PRECISION="-1" \
LABEL_REMOVE_TRAILING_ZEROS="YES" LABEL_USE_SCIENTIFIC_NOTATION="NO" LOAD_FLAGS="0~0~0~4~0~0" \
CLIP_COLLAR="NONE" SAMPLING_METHOD="NONE" AUTO_CONTRAST="NO" CONTRAST_SHARED="YES" \
CONTRAST_MODE="NONE" TEXTURE_MAP="NO"
// Import
IMPORT FILENAME="%FNAME_W_DIR%"
//Calculate NDVI
APPLY_FORMULA FILENAME="*" FORMULA="NDVI" OUTPUT_GRID=YES
//DEFINE_SHADER SHADER_NAME="NDVI Shader" BLEND_COLORS="YES" STRETCH_TO_RANGE="NO" SHADE_SLOPES="NO" \
// SLOPES_PERCENT="NO" OVERWRITE_EXISTING="NO" SAVE_SHADER="YES"
// -0.2,RGB(0,0,255)
// 0,RGB(255,255,255)
// 0.3,RGB(0,128,0)
// 0.6,RGB(0,64,0)
//END_DEFINE_SHADER
SET_VERT_DISP_OPTS SHADER_NAME="NDVI Shader"
//Export Raster
EXPORT_ELEVATION FILENAME="%DIR%%FNAME_WO_EXT%_ndvi.tif" TYPE=GEOTIFF BAND_BIT_DEPTH=32
UNLOAD_ALL
// End the loop
DIR_LOOP_END
UNLOAD_ALL
// Loop over all .tif files in a folder and convert them
DIR_LOOP_START DIRECTORY="C:\Users\rdp\NDVI\test\" FILENAME_MASKS="*.tif" TYPE="GEOTIFF" \
LABEL_FIELD_FORCE_OVERWRITE="NO" LABEL_FORMAT_NUMBERS="YES" LABEL_PRECISION="-1" \
LABEL_REMOVE_TRAILING_ZEROS="YES" LABEL_USE_SCIENTIFIC_NOTATION="NO" LOAD_FLAGS="0~0~0~4~0~0" \
CLIP_COLLAR="NONE" SAMPLING_METHOD="NONE" AUTO_CONTRAST="NO" CONTRAST_SHARED="YES" \
CONTRAST_MODE="NONE" TEXTURE_MAP="NO"
// Import
IMPORT FILENAME="%FNAME_W_DIR%"
//Calculate NDVI
APPLY_FORMULA FILENAME="*" FORMULA="NDVI" OUTPUT_GRID=YES
//DEFINE_SHADER SHADER_NAME="NDVI Shader" BLEND_COLORS="YES" STRETCH_TO_RANGE="NO" SHADE_SLOPES="NO" \
// SLOPES_PERCENT="NO" OVERWRITE_EXISTING="NO" SAVE_SHADER="YES"
// -0.2,RGB(0,0,255)
// 0,RGB(255,255,255)
// 0.3,RGB(0,128,0)
// 0.6,RGB(0,64,0)
//END_DEFINE_SHADER
SET_VERT_DISP_OPTS SHADER_NAME="NDVI Shader"
//Export Raster
EXPORT_ELEVATION FILENAME="%DIR%%FNAME_WO_EXT%_ndvi.tif" TYPE=GEOTIFF BAND_BIT_DEPTH=32
UNLOAD_ALL
// End the loop
DIR_LOOP_END
Answers
-
Hello,
When you export an elevation grid file, the data values are NDVI values, and don't include any color information. The shader can only be applied when you are viewing data in Global Mapper.
Do you still need the raw values in your data? If not, you can export the data as a raster image (EXPORT_RASTER script command). That will preserve the shader coloring, but not the NDVI values. You can also export both, then you will have an file containing the raw data, and another with the shaded view.
Cheers,
Bob -
Thanks Bob,I decided on your solution earlier today. My script now exports both a raster image and an elevation grid.I'm glad to hear that I found the correct solutionregards--bob
Categories
- 12.7K All Categories
- 5.6K Features Discussion
- 342 Downloading Imagery
- 1.3K Elevation Data
- 380 Georeferencing Imagery Discussion
- 628 GM Script Language
- 53 User Scripts
- 113 GPS Features
- 414 Projection Questions
- 819 Raster Data
- 1.3K Vector Data
- 6.6K Support
- 177 Announcement and News
- 908 Bug Report
- 558 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 562 Other Discussion
- 129 GIS Data Sources
- 27 Global Mapper Showcase
- 233 How I use Global Mapper
- 107 Global Mapper Forum Website