Test if Minimum valid Elevation is below 0

veddycentveddycent Global Mapper UserPosts: 21
Hi all,

I'm struggling with the scripting side of Global Mapper. I've gone through the sample scripts but they are very limited and the documentation doesn't offer many samples.

Here is what I'm trying to do:
1 - Loop through all layers open in Global Mapper
2 - Check if Minimum Valid Elevation in Options - Alter Elevation Values is > 0
3 - If it is make it 0, if its NOT them move to next layer

Here is what I have so far:
LAYER_LOOP_START FILENAME="*"
DEFINE_VAR NAME="VARMinElev" VALUE=SET_LAYER_OPTIONS MIN_ELEV
 
IF COMPARE_STR="VARMinElev>0" COMPARE_NUM="YES"
SET_LAYER_OPTIONS MIN_ELEV = "0"
END_IF
LAYER_LOOP_END

Any help would be much appreciated
Tagged:

Answers

  • veddycentveddycent Global Mapper User Posts: 21
    I figured it out.
    Here is the script in case its of any use to anyone:

    GLOBAL_MAPPER_SCRIPT VERSION="1.00"

    //LOOPS THROUGH ALL LOADED LAYERS AND SETS SEA LEVEL 0 IF ITS LESS THAN 0

    // Loop over the loaded layers
    LAYER_LOOP_START FILENAME="*"
    //Gets the Minimum Elevation from Metadata for the layer
    QUERY_LAYER_METADATA METADATA_LAYER="%LAYER_DESC%" METADATA_ATTR="MIN ELEVATION" RESULT_VAR="VARMinElev"

    //Display the Minimum Elevation
    LOG_MESSAGE Minimum Elevation %VARMinElev%
    //If the Minimum Elevation is LESS THAN 0
    IF COMPARE_STR="%VARMinElev%<0"
    //Set Minimum Elevation to 0
    SET_LAYER_OPTIONS FILENAME="%LAYER_DESC%" MIN_ELEV=0
    //Clamp to 0
    SET_LAYER_OPTIONS FILENAME="%LAYER_DESC%" CLAMP_ELEVS=1
    //Fill all the empty space with 0 elevation (Sea Level)
    SET_LAYER_OPTIONS FILENAME="%LAYER_DESC%" VOID_ELEV=0
    END_IF
    LAYER_LOOP_END
Sign In or Register to comment.