Global Mapper Scripting Language Reference

General Overview

Global Mapper script files allow the user to create custom batch processes that make use of the functionality built in to Global Mapper. From a script, one can import data in any of the numerous formats supported by the software, reproject that data if desired, and export it to a new file.

Global Mapper script files consist of a series of command lines. Each command line begins with a command. A series of parameter/value pairs should follow the command. These pairs should be written as parameter=value. No spaces should exist before or after the equal sign. Individual parameter/value pairs should be separated by spaces. If a pair requires spaces internal to the value, quotes may be used around the entire value. For example, for a filename with spaces, the pair could look like FILENAME="c:\\my documents\\test.tif". Parameters that expect a value of YES or NO to enable or disable functionality can (starting with v13.1) be enabled with just the parameter name. So rather than saying FLAG_PARAM_NAME=YES, you can just say FLAG_PARAM_NAME to get the same behavior as specifying yes.

Command lines typically consist of one line each. To extend a command to another line, use the backslash character (\) at the end of the line. There are a few exceptions to this, including the DEFINE_PROJ and DEFINE_SHAPE commands and the looping functionality provided by the DIR_LOOP_START and DIR_LOOP_END commands.

Batch Mode Operation

You can run a Global Mapper script file automatically by passing it on the command line to the Global Mapper .exe file. The script file will be run with no user interface displayed and Global Mapper will immediately exit when the script file completes processing. This allows you to easily run Global Mapper scripts from another application or from a DOS batch file. Note that your script files need to have an extension of .gms for this to work.

Batch variables

When running in batch mode you can define variables on the command line so they will be available when running the script. You provide pairs of tokens on the command line, after the file name. Each pair must look like:

-<var name> <var value>

or

/<var name> <var value>

Example command line:


global_mapper.exe "c:\temp\myscript.gms" -var1 01 -var2 33

This defines two variables that can be used in the script: var1=01 and var2=33. See the DEFINE_VAR command for details on how to use variables.

Batch options

/showprogress - if present, instructs Global Mapper to display progress bars while processing a script. This parameter only has an effect when running a script from the command line.

Example command line: 

"C:\Program Files\GlobalMapper17_64bit\global_mapper.exe" "C:\Scripts\export.gms" /showprogress

Comments

Any lines that begin with the forward slash character (/) are considered comments and are ignored by the script processing engine. This means that you can use C or C++ style comments like // or /* at the start of your line.

Conditional Execution in Global Mapper Scripts

Global Mapper scripts can incorporate conditional logic through the use of the IF, ELSE_IF, ELSE, and END_IF commands. At a minimum, when incorporating conditional logic into a script, the user must use an IF and an END_IF command, as in the following example:


IF COMPARE_STR="%VAR1%=val1"

// Additional script commands to be run when the condition is true.

END_IF

When the script containing the sample is run, if the value of the variable %VAR1% is "val1", the statements following the IF and before the END_IF will be executed. If the value of variable %VAR1% is something other than "val1", then the statements following the IF will be skipped, and script processing will continue with the first statement after the END_IF. If the user wants to run a specific set of commands in the case where the condition specified on the IF is not true, then he can use the ELSE command:


IF COMPARE_STR="%VAR1%=val1"

// Script commands to be run when the IF condition is true.

ELSE

// Script commands to be run when the IF condition is false.

END_IF

Now, if the value of the variable %VAR1% is "val1", the statements following the IF and before the ELSE will be executed, and the commands after the ELSE and before the END_IF will be skipped. If the value of variable %VAR1% is something other than "val1", then the statements following the IF and preceding the ELSE will be skipped, and the commands after the ELSE and before the END_IF will be run.

If the user has several conditions that need to be tested, only one of which can be true, then the ELSE_IF command can be used:


IF COMPARE_STR="%VAR1%=val1"

// Script commands to be run when the IF condition is true.

ELSE_IF COMPARE_STR="%VAR1%=val2"

// Script commands to be run when the ELSE_IF condition is true.

ELSE

// Script commands to be run when the all other conditions are false.

END_IF

The commands following the IF will be handled as described above, but now there is a second condition being tested. When the value of variable %VAR1% is "val2", then the commands after the ELSE_IF and before the ELSE will be run. In the case where there are multiple IF/ELSE_IF conditions, the commands after the ELSE will be run when all of the other conditions are false.

Logical Conditions

The IF and the ELSE_IF commands require a COMPARE_STR parameter to specify the condition to be tested. The user can specify multiple COMPARE_STR parameters, all of which must be true to result in the subsequent commands being executed (logical AND). Use the COMPARE_OP="ANY" parameter to specify that the subsequent commands should be run if any one of the conditions is true (logical OR).

The COMPARE_STR must consist of <value><operation><value>, where either value can be a constant or a variable name (enclosed in "%"). Both values must be specified. The operation is also required, and can be one of:

By default, the comparison will be a case-insensitive string comparison. If you want to perform a numeric comparison, specify the COMPARE_NUM="YES" parameter.

IF commands can be nested, so the block of commands following an IF, ELSE_IF, or ELSE command can contain another IF command:


IF COMPARE_STR="%VAR1%=val1"

 IF COMPARE_STR="%VAR2%>10"

 // Script commands to be run when the IF condition is true.

 END_IF

ELSE

 // Script commands to be run when the IF condition is false.

END_IF

Loops

Commands

ADD_MEASURE_ATTRS

The ADD_MEASURE_ATTRS command allows you to add/update feature measure attributes to all of the line and area features in a loaded vector layer.

The following parameters are supported by the command:

APPLY_FORMULA

The APPLY_FORMULA command allows you to apply a mathematical formula to the bands in one or more loaded raster layers to create a new raster or grid layer. This is useful for doing things like NDVI or NDWI calculations from multi-spectral imagery, among a large array of other multi-spectral analysis.

The following parameters are supported by the command:

SAMPLE

Here is an example script command showing how to apply a formula to all currently loaded raster layers.


GLOBAL_MAPPER_SCRIPT VERSION=1.00

APPLY_FORMULA FILENAME="*" OUTPUT_BIT_DEPTH="8" FORMULA="IF(B1<90, B1*0.765+20, B1)" 

CALC_ATTR

The CALC_ATTR command allows you to calculate a new attribute value (or update the value for an existing attribute) for features in a layer based on a source attribute (including things like the feature label or type) and a second value. The second value can be a specified string or number, or the value from another attribute of the feature.

The following parameters are supported by the command:

SAMPLE

Here is a sample of creating a new elevation attribute in feet from an elevation attribute (ELEV_M) in meters, including with an appended unit string.


GLOBAL_MAPPER_SCRIPT VERSION=1.00

// Create new ELEV_FT attribute with attribute in feet in any loaded layers

CALC_ATTR TYPE="MULTIPLY" NEW_ATTR="ELEV_FT" SOURCE_ATTR="ELEV_MT" VALUE="3.2808"

// Append the unit name to the new attribute

CALC_ATTR TYPE="APPEND" NEW_ATTR="ELEV_FT" SOURCE_ATTR="ELEV_FT" VALUE=" ft"

CALC_ATTR_FORMULA

The CALC_ATTR_FORMULA command allows you to calculate a new attribute value (or update the value for an existing attribute) for features in a layer, based on a formula that may contain numbers, strings or other attributes. A number of functions may be used as well.

The following parameters are supported by the command:

SAMPLE

Here is a sample of creating a new elevation attribute in feet from an elevation attribute (ELEV_M) in meters, including with an appended unit string.


GLOBAL_MAPPER_SCRIPT VERSION=1.00

// Create new ELEV_FT attribute with attribute in feet in any loaded layers

CALC_ATTR_FORMULA NEW_ATTR="ELEV_FT" FORMULA="ELEV_MT * 3.2808"

// Append the unit name to the new attribute

 CALC_ATTR_FORMULA NEW_ATTR="ELEV_FT" FORMULA="ELEV_FT + ' ft'"

CALC_VOLUMES

The CALC_VOLUMES command allows you to calculate the volume for each area in the specified layer using the currently loaded terrain data.

The following parameters are supported by the command:

SAMPLE

Here is a sample of calculating volumes in cubic feet, adding the results to the features as attributes.


GLOBAL_MAPPER_SCRIPT VERSION=1.00

CALC_VOLUMES FILENAME="boundaries 2.dxf" ADD_VOLUME_ATTRS=YES 



CALC_VOLUME_BETWEEN_SURFACES

Calculates the volume between two elevation grids. If you specify an area layer, the volume will be calculated for each feature, and volume attributes will be added to the feature. The following parameters are supported by the command:

SAMPLE

CALC_VOLUME_BETWEEN_SURFACES LAYER1_FILENAME="P:\Data\baseGrid.tif" \

LAYER2_FILENAME="P:\Data\lidarGrid2.dem" \

AREA_FILENAME="P:\Data\ClipAreas.shp" \

VOLUME_UNIT="CUBIC_FEET" \

OUTPUT_FILENAME="%OUTDIR%\fromScript_wClip.csv"

COMBINE_LINES

The COMBINE_LINES command allows you to combine connected lines features based on one or more attribute or label values. You can choose to combines in just a single loaded layer or in all loaded vector layers. You can either create new line features from the connected lines, or using the CREATE_AREAS_FROM_LINES parameter instead create new area features by connecting the lines into closed shapes. The newly created features will be placed in a new layer and have the current projection. If creating lines, any lines that are connected to another line will be marked as deleted. You can also supply multiple COMPARE_STR parameters to apply multiple criteria, all of which must be true, in order for the lines to be considering for combining.

The following parameters are supported by the command:

COMBINE_TERRAIN

The COMBINE_TERRAIN command generates a new terrain (gridded elevation) layer by combining two loaded terrain layers through some operation, like addition, subtraction (difference), average, min/max, etc. The new terrain layer can then be operated on just like any other terrain layer.

The following parameters are used by the COMBINE_TERRAIN command:

COPY_ATTRS

The COPY_ATTRS command copies one or more attributes from one layer of features to another. The attributes are copied spatially between feature types, like copying point attributes to the area features those points are contained in, etc. Not every combination of feature types is supported for copying. If you choose a combination that is not supported (like LINES to LINES) you will get an error message.

The following parameters are used by the COPY_ATTRS command:

SAMPLE


GLOBAL_MAPPER_SCRIPT VERSION="1.00"

/* Copy all loaded area attributes to the points in the area */

COPY_ATTRS LAYER1_FILENAME="*" FROM_TYPE="AREAS" LAYER2_FILENAME="*" TO_TYPE="POINTS"

COPY_LAYER_FILES

The COPY_LAYER_FILES command copies the base files for one or more layers to a new folder on disk. Support is included for maintaining folder structures if a BASE_DIR parameter is provided. If you specify layers that were loaded from .zip or .tar.gz archives, the archive file itself will be copied and not the individual extracted files. If you specify a file with supporting files with the same base name (i.e foo.tfw and foo.prj with foo.tif loaded) they will also be copied.

The following parameters are used by the COPY_LAYER_FILES command.

SAMPLE


GLOBAL_MAPPER_SCRIPT VERSION="1.00"

/* Copy all loaded layer files to a new folder */

COPY_LAYER_FILES TARGET_DIR="C:\NEW_DEMS" BASE_DIR="c:\data\my_dems" OVERWRITE_EXISTING=YES

CROP_AREAS_TO_LINES

The CROP_AREAS_TO_LINES tool crops or splits areas based on line features. It uses the following parameters:

DEFINE_LAYER_STYLE

The DEFINE_LAYER_STYLE command allows you to define a layer style for the area, line, or point features in a vector layer. You can then apply this with the IMPORT or SET_LAYER_OPTIONS command later.

The DEFINE_LAYER_STYLE command consists of a single command line followed by a series of lines with the contents of a .gm_layer_style file, like you would save from the Area Styles, Line Styles, or Point Styles tab of the Options dialog for a vector layer. You can also provide a .gm_layer_style in the FILENAME parameter to just reference an external file rather than embedding the layer style directly in the script file.

The DEFINE_LAYER_STYLE command is terminated with a single line containing only the text END_DEFINE_LAYER_STYLE.

For a sample of the DEFINE_LAYER_STYLE command in use, load some data and set up some attribute-based or other custom styling on the Styles tabs of the Options dialog, then save a Global Mapper workspace file from the File->Save Workspace menu command. Open the resulting .gmw file in an editor and you can see how the DEFINE_LAYER_STYLE command is used to define a layer style and then use it in the IMPORT command.

The following parameters are required by the DEFINE_LAYER_STYLE command.

DEFINE_PROJ

The DEFINE_PROJ command allows a projection (including datum) to be associated with a name. The projection name can then be used in later IMPORT, IMPORT_ARCHIVE, IMPORT_ASCII, and LOAD_PROJECTION commands to specify a projection as needed.

The DEFINE_PROJ command consists of a single command line followed by a series of lines describing the projection in the format of an ESRI PRJ file. The easiest way to determine the text for a projection is to setup a projection on the Projection tab of the Tools->Configuration and then use the Save to File button to create a new .prj file. Then just open the .prj file up in Notepad and copy the contents to the lines following the DEFINE_PROJ command line.

The DEFINE_PROJ command is terminated with a single line containing only the text END_DEFINE_PROJ.

For a sample of the DEFINE_PROJ command in use, load some data and then save a Global Mapper workspace file from the File->Save Workspace menu command. Open the resulting .gmw file in an editor and you can see how the DEFINE_PROJ command is used to define a view projection and the set it.

The following parameters are required by the DEFINE_PROJ command.

DEFINE_SDB_CONNECTION

The DEFINE_SDB_CONNECTION allows the user to define a connection and use that definition in the script. This is required for enterprise spatial databases that require a defined connection, but is not needed for exporting to a file-based spatial database such as Esri Personal Geodatabase or Spatialite/SQLite.

Using the SAVE_CONNECTION parameter will cause this definintion to be stored with the connections defined using the Connection Manager.

SAMPLE


DEFINE_SDB_CONNECTION TYPE="POSTGIS" SDB_CONNECTION_NAME="PostGIS" \

 SDB_SERVER="myserver" SDB_PORT="5432" SDB_DATABASE_NAME="mydb" \

 SDB_SAVE_USER_AND_PASSWORD="YES" SDB_USER_NAME="pguser" \

 SDB_PASSWORD="pgpassword" SAVE_CONNECTION=YES

DEFINE_SHADER


The DEFINE_SHADER command allows a custom elevation/slope shader to be defined to be used when rendering gridded elevation data. The shader will then be available for any other operations and later Global Mapper runs. If there is an existing custom shader with the same nameit will be replaced.

The DEFINE_SHADER command consists of a single command line followed by a series of lines describing the series of elevation/slope and color pairs that define the shader. Each line should have a single elevation/slope value and a color value separated by a comma.

The DEFINE_SHADER command is terminated with a single line containing only the text END_DEFINE_SHADER.

The following parameters are required by the DEFINE_SHADER command.

SAMPLE

Here is an example of a DEFINE_SHADER command used to define a sample 3-color blended shader.


DEFINE_SHADER SHADER_NAME="Script Shader" BLEND_COLORS=YES STRETCH_TO_RANGE=YES SHADE_SLOPES=NO

 0.0,RGB(255,0,0)

 20.0,RGB(0,255,0)

 50.0,RGB(0,0,255)

END_DEFINE_SHADER

DEFINE_SHAPE

The DEFINE_SHAPE command allows a multi-point shape (like a polygon) to be associated with a name. The shape name can then be used in later commands for things like cropping and feathering to polygonal boundaries.

The DEFINE_SHAPE command consists of a single command line followed by a series of lines describing the series of XY coordinate pairs that define the shape. Each line should have a single coordinate value with the X and Y coordinates separated by a comma. If you need your shape to contain multiple boundaries, insert BREAK_SHAPE on a line to stop the current sequence and start a new one.

The DEFINE_SHAPE command is terminated with a single line containing only the text END_DEFINE_SHAPE.

The following parameters are required by the DEFINE_SHAPE command.

SAMPLE

Here is an example of a DEFINE_SHAPE command used to define a feather polygon with a name of 'FEATHER_POLY'


DEFINE_SHAPE SHAPE_NAME="FEATHER_POLY"

	377493.234,4323974.016

	375343.359,4318676.109

	381101.953,4314414.750

	387014.109,4317178.875

	386975.719,4322400.000

	381869.766,4324588.266

	377493.234,4323974.016

END_DEFINE_SHAPE

Here is an example of a DEFINE_SHAPE command used to define a feather polygon with 2 separate boundaries with a name of 'FEATHER_POLY'


DEFINE_SHAPE SHAPE_NAME="FEATHER_POLY"

	377493.234,4323974.016

	375343.359,4318676.109

	381101.953,4314414.750

	387014.109,4317178.875

	377493.234,4323974.016

 BREAK_SHAPE

	386975.719,4322400.000

	381869.766,4324588.266

	377493.234,4323974.016

	386975.719,4322400.000

END_DEFINE_SHAPE

DEFINE_TEXT_FILE

The DEFINE_TEXT_FILE command allows an ASCII text file containing the definition of vector features to be associated with a name. You can then use the associated name in the FILENAME parameter of the IMPORT_ASCII command to load the file contents as if they were an external file. This is a powerful command allowing you to embed the definition of vector features directly within a script.

The associated name can also be used with the DIR_LOOP_START command where the definition includes a list of filepaths.

The DEFINE_TEXT_FILE command consists of a single command line followed by a series of lines with the contents of the text "file". The DEFINE_TEXT_FILE command is terminated with a single line containing only the text END_DEFINE_TEXT_FILE.

 

The following parameters are required by the DEFINE_TEXT_FILE command.

SAMPLE

Here is an example of a DEFINE_TEXT_FILE command used to define a couple of feature shapes.


DEFINE_TEXT_FILE FILENAME="Test Features"

GM_TYPE=Lake, < 0.5 sq. mi.

DESCRIPTION=LAKE OR POND

BORDER_COLOR=RGB(0,0,0)

BORDER_STYLE=Null

FILL_COLOR=RGB(0,0,211)

FILL_STYLE=Solid Fill

CLOSED=YES

LABEL_POS=382285.8,4331317.0

DLGMAJ_0=50

DLGMIN_0=421

382277.3,4331322.5

382297.4,4331322.5

382297.4,4331322.5

382290.6,4331312.0

382277.7,4331311.0

382277.7,4331311.0

382277.3,4331322.5

GM_TYPE=Minor River

DESCRIPTION=STREAM

BORDER_COLOR=RGB(0,0,0)

BORDER_STYLE=Null

FILL_COLOR=RGB(0,0,211)

FILL_STYLE=Solid Fill

CLOSED=YES

LABEL_POS=381081.4,4319924.0

DLGMAJ_0=50

DLGMIN_0=412

381269.3,4320021.0

381288.4,4320030.0

381298.8,4320037.0

381330.0,4320081.5

381359.7,4320117.0

381380.0,4320130.0

381397.2,4320136.0

381419.2,4320136.5

381460.5,4320125.5

381517.1,4320120.5

381554.9,4320121.5

381627.6,4320133.0

381665.4,4320135.5

381684.3,4320131.5

381707.9,4320122.0

381725.6,4320118.5

381733.4,4320112.5

END_DEFINE_TEXT_FILE

DEFINE_VAR

The DEFINE_VAR command allows you to define a variable and an associated value. You can then use the defined variable name later wrapped in percent signs to have the defined value replaced in the script. This is useful for things like defining a path or something at the top of a script that you can easily change in just one place later. You can also pass variables on the command line for truly power batch-mode operation.

Built-in Variables

There are several built-in variable names that you can use to easily insert things like the current date and time. The following variable strings can be used without having to define them:

The following parameters are required by the DEFINE_VAR command.

SAMPLE

Here is an example of a DEFINE_VAR command used to define a directory path for later use and then its subsequent use:


DEFINE_VAR NAME="DATA_DIR" VALUE="c:\temp\export test"

IMPORT FILENAME="%DATA_DIR%\blue_springs.opt"

For example you could use the following inside a directory loop to change the output path:


DEFINE_VAR NAME="OUT_FNAME" VALUE="%FNAME_W_DIR%" REPLACE_STR="OLD_PATH\=NEW_PATH\SUB_FOLDER\"

Example to define a variable based on the F_CODE attribute of a loaded layer and then use that in the layer description of the layer.


DEFINE_VAR NAME="LAYER_F_CODE" VALUE_ATTR="F_CODE" FILENAME="c:\path_to_layer\my_data.shp"

SET_LAYER_OPTIONS FILENAME="c:\path_to_layer\my_data.shp" LAYER_DESC="%LAYER_F_CODE%"

Example to prompt the user for a folder and then a .zip file in that folder (you could have just prompted for the file all at once, but this is for demonstration), then loads it.


// Prompt for folder to load

DEFINE_VAR NAME="DIR_TO_LOAD" PROMPT="DIR" VALUE="d:\temp\export test\" ABORT_ON_CANCEL=NO

// Prompt for .zip file to load in folder. Cancel if nothing selected.

DEFINE_VAR NAME="FILE_TO_LOAD" PROMPT="FILE" VALUE="%DIR_TO_LOAD%.zip" ABORT_ON_CANCEL=YES

// Load the file.

IMPORT FILENAME="%FILE_TO_LOAD%"

Example to prompt the user for a filename, then define new variables that hold pieces of the selected filename.


// Prompt use for file. Script aborts on cancel

DEFINE_VAR NAME="FULL_FNAME" PROMPT=FILE ABORT_ON_CANCEL=YES

// Define a variable with just the filename, another with parent folder

DEFINE_VAR NAME="FNAME_ONLY" VALUE="%FULL_FNAME%" FILENAME_PIECE="FNAME_WO_EXT"

DEFINE_VAR NAME="FNAME_PARENT_DIR" VALUE="%FULL_FNAME%" FILENAME_PIECE="PARENT_DIR"

DEFINE_VAR NAME="FNAME_PARENT_DIR1" VALUE="%FULL_FNAME%" FILENAME_PIECE="PARENT_DIR1"

DEFINE_VAR_TABLE

The command can be used to set up a look-up table in the script. Once the table is set up, you can use a DEFINE_VAR command to set up a script variable by looking up a value in the table. The data that makes up the table can be specified inline, or read from a CSV file. GM assumes that the first line of the data contains the column names for the table. This is true regardless of whether the data is inline or in a file.

END_VAR_TABLE - Indicates the end of the DEFINE_VAR_TABLE command. This is always required, whether the data is specified inline or in a file.

The following parameters are required by the DEFINE_VAR_TABLE command.

SAMPLES

Example (data specified inline):


DEFINE_VAR_TABLE NAME="state_codes"

st_code,st_abb,st_name

06,ca,"california,xyz"

08,co,colorado

END_VAR_TABLE

DEFINE_VAR NAME="st_abb1" VALUE_TABLE="state_codes" VALUE_COLUMN="st_abb" \

COMPARE_STR="st_code=06"

DEFINE_VAR NAME="st_name1" VALUE_TABLE="state_codes" VALUE_COLUMN="st_name" \

COMPARE_STR="st_code=06"

Example (data in a file):


DEFINE_VAR_TABLE NAME="state_codes" \

FILENAME="C:\Temp\GlobalMapperWorkspaces\test_tabl e.csv"

END_VAR_TABLE

DEFINE_VAR NAME="st_abb5M" VALUE_TABLE="state_codes" VALUE_COLUMN="st_abb" \

COMPARE_STR="st_code=09"

DEFINE_VAR NAME="st_name5M" VALUE_TABLE="state_codes" VALUE_COLUMN="st_name" \

COMPARE_STR="st_code=09"

The example CSV file contains the following data:


st_code,st_abb,st_name

06,ca,"california,xyz"

08,co,colorado

09,me,maine

DIR_LOOP_END

The DIR_LOOP_END command ends a loop of commands over all of the folders within a directory. See the DIR_LOOP_START command for details.

DIR_LOOP_START

The DIR_LOOP_START command begins a loop of commands over all of the folders within a directory (and optionally its subdirectories) that match one or more filename masks. This is a powerful feature allowing you to do things like easily batch convert a collection of files or perform any other supported operation over a collection of files. You end a loop over the files in a folder using the DIR_LOOP_END command. Note that it is also possible to nest loops.

Built-in Variables

For any commands found within a DIR_LOOP_START...DIR_LOOP_END pair defining a loop, the following special character sequences can be used anywhere (examples of what the values will be based on a current filename of 'C:\path\to\my\data\my_file.dem' are listed):

For a sample of the DIR_LOOP_START command in use, see the example at the bottom of this reference.

The following parameters are used by the DIR_LOOP_START command.

EDIT_MAP_CATALOG

The EDIT_MAP_CATALOG command allows you to work with map catalogs (managed collections of map files), including create new map catalogs, adding maps to existing map catalogs, and removing maps from existing map catatalogs.

The following parameters are supported by the command:

SAMPLES

Here is a sample showing how to create a map catalog and then load it:


// Create the map catalog. Maps should show when they take up at least 10% of display.

EDIT_MAP_CATALOG FILENAME="C:\TEMP\EXPORT TEST\script_catalog.gmc" CREATE_IF_EMPTY=YES \

 ADD_FILE="c:\temp\export test\*.tif" ADD_FILE="c:\temp\export test\*.dem" \

 ZOOM_DISPLAY="PERCENT,0.10,0"

 

// Load the map catalog

IMPORT FILENAME="c:\temp\export test\script_catalog.gmc"

EDIT_VECTOR

The EDIT_VECTOR command selects and modifies vector data. You can choose to update area, line, and/ or point features with a single operation. You can also supply multiple COMPARE_STR parameters to apply multiple criteria, all of which must be true, in order to edit a feature.

It allows you to assign feature types (classifications), add/update attributes and display labels, and reshape or delete features based on one or more attribute or label values.

The following parameters are supported by the command:

Specify Data to Edit (By Attribute and/or Bounding Box)

Specify Layer for Output - Default is Input Layer

Attribute and Style Editing

Duplicate Feature Finding

Apply Terrain Elevations to Vector Data

Buffer Creation

The following parameters control creation of buffer areas around matching features:

Other Feature Editing

SAMPLES

Here is an example illustrating how to move features with a CLASS attribute with a value of '1' to a new layer named 'Major Highways':


EDIT_VECTOR MOVE_TO_NEW_LAYER=YES NEW_LAYER_NAME="Major Highways" \

 COMPARE_STR="CLASS=1"

Here is an example illustrating how to add evenly spaced points every 200 meters along the features containing a CLASS attribute with a value of '1'. Point features will also be created at the end point, and at each current vertex:


EDIT_VECTOR CREATE_POINTS_ALONG_FEATURES=200 COMPARE_STR="CLASS=1" \

 KEEP_END_POINT=YES KEEP_ORIGINAL_VERTICES=YES

Here is an example illustrating how to add evenly spaced perpendicular lines, 50 meters long, every 250 meters along the features containing a CLASS attribute with a value of '2'. Line features will also be created at the end point:


EDIT_VECTOR CREATE_PERP_LINES_ALONG_FEATURES=250 PERP_LINE_LENGTH=50 COMPARE_STR="CLASS=2" \

 KEEP_END_POINT=YES

Here is a sample script demonstrating applying elevations to all loaded vector data from all loaded terrain:

GLOBAL_MAPPER_SCRIPT VERSION=1.00
// Apply elevations from all loaded terrain layers to all loaded vector layer.
// Do NOT add elev values to existing values and do NOT include unit suffix.
// If the data already has an existing elevation, do NOT replace it
// Assign elevations for points to the ELEV_1 attribute rather than ELEVATION
EDIT_VECTOR APPLY_ELEVS=YES ADD_EXISTING_ELEV=NO INC_UNIT_SUFFIX=NO \
REPLACE_EXISTING=NO ELEV_ATTR="ELEV_1"

For more examples of how to use the EDIT_VECTOR command, see the sample at the bottom of this document.

EMBED_SCRIPT

The EMBED_SCRIPT command allows you to call another script from within a script or to load a workspace file. This can be useful in many situations. For example, if you have a common set of data files that you want to load for each script operation, you could simply create a script that loaded those files, then embed that script within your other scripts.

The following parameters are supported by the command:

EXPORT_ANY

The EXPORT_ANY command exports loaded data to some file format. The TYPE parameter for this will automatically determine which of the EXPORT_ELEVATION, EXPORT_PACKAGE, EXPORT_PDF, EXPORT_RASTER, or EXPORT_VECTOR commands should be used. For example if you use TYPE=USGS_DEM then you will export using the EXPORT_ELEVATION command. The parameters for the command that is used based on the TYPE parameter.

EXPORT_CLOUD

The EXPORT_CLOUD command exports data to a cloud database, including Amazon S3 account. The following parameters are supported by the command.

EXAMPLE

EXPORT_CLOUD GEN_PRJ_FILE=YES TYPE="SHAPEFILE" \
ELEV_UNITS="METERS" LABEL_FIELD_FORCE_OVERWRITE="YES" LABEL_FIELD_SEP="0x20" LABEL_FIELD="NAME" \
CODE_PAGE="0" CLOUD_TYPE="Amazon's AWS S3" CLOUD_KEY1="AAAAAAAAAAAAAAAAAAAA" CLOUD_KEY2="AAAA+bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" \
CLOUD_FOLDER="bmg-bucket" CLOUD_LOCATION="us-east-1" CLOUD_FILE="biggybig.shp"

EXPORT_ELEVATION

The EXPORT_ELEVATION command exports all currently loaded elevation data to a file. The following parameters are supported by the command.

BIL Grid Fields

XYZ Grid Fields

ERDAS Fields

GeoTIFF Fields

FLOAT_GRID Fields

DTED Fields

Lidar LAS/LAZ Fields

Arc ASCII Grid Fields

GWS Windsim Fields

Other Format Specific Fields

SAMPLES

Here is an example script showing 2 GWS exports:

GLOBAL_MAPPER_SCRIPT VERSION=1.00
// Do export with elev/roughness layers separately specified
EXPORT_ELEVATION TYPE="GWS" FILENAME="output.gws" \
ELEV_LAYER="*blue_springs*.dem*" ROUGHNESS_LAYER="Roughness *"
// Do export with automatic layer selection
EXPORT_ELEVATION TYPE="GWS" FILENAME="output_auto.gws"

EXPORT_METADATA

The EXPORT_METADATA command exports the metadata for a specified load layer. The following parameters are supported by the command.

EXPORT_PACKAGE

The EXPORT_PACKAGE command exports all currently loaded raster, vector, and elevation data to a Global Mapper Package (GMP) file. The following parameters are supported by the command.

EXPORT_PDF

The EXPORT_PDF command exports all currently loaded data to a PDF file. The following parameters are supported by the command.

EXPORT_PDF3D

The EXPORT_PDF3D command exports all currently loaded data to a 3D PDF file. The following parameters are supported by the command.

EXPORT_RASTER

The EXPORT_RASTER command exports all currently loaded raster, vector, and elevation data to a file. The following parameters are supported by the command.

GeoTIFF Fields

KML/KMZ Fields

BSB Fields

RPF (CADRG/CIB) Fields

ADRG/ASRP Fields

EXPORT_VECTOR

The EXPORT_VECTOR command exports all currently loaded vector data to a file. The following parameters are supported by the command.

Splitting Exports by Attribute Fields

DXF/DWG Fields

Exporting Vector Files to a Spatial Database

Polish MP Fields

DGN Fields

KML/KMZ Fields

Lidar LAS/LAZ Fields

Lidar Point Filter Options

GPX Fields

EXPORT_WEB

The EXPORT_WEB command exports all currently loaded data to a tiled web format. The following parameters are supported by the command.

FORCE_EXIT

The FORCE_EXIT command aborts the script and optionally immediately shuts down Global Mapper without going through the normal shut-down process. This is useful if you are running a Global Mapper script via a CreateProcess call and the Global Mapper process is not returning when the script completes, or if you need a particular return code provided. The following parameters are supported by this command:

GENERATE_CONTOURS

The GENERATE_CONTOURS command allows for the generation of contour lines (isolines of equal elevation) from any or all currently loaded elevation data. The following parameters are supported by the command.

GENERATE_ELEV_GRID

The GENERATE_ELEV_GRID command allows for the generation of a gridded elevation layer using loaded 3D vector data. The following parameters are supported by the command as well as the display option paramters supported by the IMPORT command.

Lidar Point Filter Options

GENERATE_EQUAL_VAL_AREAS

The GENERATE_EQUAL_VAL_AREAS command allows for the generation of areas for regions of the same (or similar) color, elevation, or slope values from a loaded raster or elevation layer.

SAMPLE

This sample will generate equal-elevation areas of size 20 meters (10 meters on either side) from the specified DEM layer and store the elevation values in an attribute named ELEV for each area feature.


GENERATE_EQUAL_VAL_AREAS FILENAME="C:\temp\export test\blue_springs_4_quads.dem" ELEV_DIST=10.0 ATTR_NAME="ELEV"

GENERATE_LAYER_BOUNDS

The GENERATE_LAYER_BOUNDS command create a new layer with a single bounding box area created from the bounding box of each loaded layer or a polygonal coverage of the valid data in the layer if specified by the BOUNDS_TYPE parameter:

GENERATE_PATH_PROFILE

The GENERATE_PATH_PROFILE command allows for the saving of a 3D path profile to an ASCII XYZ file. This command uses loaded elevation data to generate a list of the 3D coordinates between two given points in the given elevation units. The following parameters are supported by the command.

GENERATE_POINTS_FROM_ELEV_GRID

Creates a point feature at the center of each cell in the specified elevation grid layer(s).

The available parameters for the command include:

Example:

GENERATE_POINTS_FROM_ELEV_GRID FILENAME="elev_grid.gmg" \

LAYER_DESC="grid_points" \

POLYGON_CROP_FILE="CropAreas.shp" POLYGON_CROP_USE_ALL=YES

GLOBAL_MAPPER_SCRIPT

The GLOBAL_MAPPER_SCRIPT must be the first command in the file. Typically, the entire command line will look like:

GLOBAL_MAPPER_SCRIPT VERSION=1.00

You can use the following parameters with this command:

GENERATE_REPORT

The GENERATE_REPORT command allows you to generate a CSV text report file on the data in one or more loaded layers broken down by a particular attribute value, feature name, or type, or just a single line report about all features. The report will include the count of area, line, and point features matching the specified criteria as well as the total combined length of the line features and combined covered area of the area features.

The following parameters are supported by the command:

GENERATE_VIEWSHED

The GENERATE_VIEWSHED command allows you to perform a view shed analysis using loaded elevation grid data with a user-specified transmitter location, height, and radius. All areas within the selected radius that have a clear line of sight to the transmitter are colored with a user-specified color.

The parameters are:

GENERATE_WATERSHED and GENERATE_RIDGE_LINES

The GENERATE_WATERSHED command allows for the generation of a watershed, including stream flow and optionally watershed areas for each stream segment. The GENERATE_RIDGE_LINES command shares the same parameters, but finds ridge lines rather than stream lines. A ridge line is created wherever flow would accumulate in the inverse of the terrain surface. The following parameters are supported by the command.

IMPORT

The IMPORT command imports a data file for later use. The following parameters are supported by the command.

Elevation Parameters

- specifies parameters for working with elevation values in terrain layers

Vector Label Parameters

- the parameters below allow specifying a how to create display labels for vector layers.

Vector Style/Type Parameters

- the parameters below allow specifying styles for the vector features.

Layer Rectification/ Control Points

- the parameters below allow defining a series of control points and rectification parameters for setting up a coordinate mapping from pixel space to real-world projection coordinates for the layer.

Lidar Display Parameters

- the parameters below allow specifying options for working with Lidar data.

IMPORT_ARCHIVE

The IMPORT_ARCHIVE command imports a data file from a .tar.gz archive for later use. The only time you should ever need to use the IMPORT_ARCHIVE command is when you only want to load some of the data inside a .tar.gz archive. For the typical case of just loading everything in an archive, use the IMPORT command with AUTO as the value for the TYPE parameter. The following parameters are supported by the command.

IMPORT_ASCII

The IMPORT_ASCII command imports data from a generic ASCII text file for later use. The following parameters are supported by the command. In addition, all of the option parameters for the IMPORT command are also supported for this command.

Distance-Bearing Type Parameters

The following parameters are applicable when loading a file set as TYPE=DIST_BEARING , TYPE=DIST_BEARING_LINE or TYPE=DIST_BEARING_SEGS

SAMPLE


IMPORT_ASCII FILENAME="C:\data\ASCII Files\usvi_landmark.asc" TYPE=POINT_AND_LINE COORD_DELIM=AUTO COORD_ORDER=X_FIRST COORD_PREFIX="XY,"INC_COORD_LINE_ATTRS=NO

IMPORT_CLOUD

The IMPORT_CLOUD command imports data from a cloud dataset, including Amazon S3 account. The following parameters are supported by the command.

EXAMPLE

IMPORT_CLOUD FILENAME="C:\data\bilbo.shp" TYPE="SHAPEFILE" \

ELEV_UNITS="METERS" LABEL_FIELD_FORCE_OVERWRITE="YES" LABEL_FIELD_SEP="0x20" LABEL_FIELD="NAME" \

CODE_PAGE="0" CLOUD_TYPE="Amazon's AWS S3" CLOUD_KEY1="AAAAAAAAAAAAAAAAAAAA" CLOUD_KEY2="AAAA+bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" \

CLOUD_FOLDER="bmg-billingbucket" CLOUD_LOCATION="us-east-1" CLOUD_FILE="bilbo.shp"

IMPORT_DIR_TREE

The IMPORT_DIR_TREE command imports all of the data files in a given directory tree that match a list of filename masks. The following parameters are supported by the command. In addition, all of the option parameters for the IMPORT command are also supported for this command.

SAMPLE


IMPORT_DIR_TREE DIRECTORY="C:\TEMP\EXPORT TEST" FILENAME_MASKS="*.OPT *.GMP"

IMPORT_OSM_TILE

The IMPORT_OSM_TILE command imports a tiled online layer using the OSM, TMS, Google Maps, or Bing Maps tile schema. The following parameters are supported by the command:

Specify Tiling Type

- By default the OSM tile naming schema is assumed, but you can use the parameters below to specify Google Maps or TMS tiling. If you specify a full custom URL in OSM_BASE_URL then the tiling schema doesn't matter as much since the URL defines the naming.

Specify Bounds for Layer

  - Use the parameters below to define the bounding box to import from the source:

SAMPLE

Here is an example of an IMPORT_OSM_TILE command that pulls in MapQuest OpenStreetMap data within 5 km of Blue Marble's headquarters:


IMPORT_OSM_TILE OSM_BASE_URL="http://otile1.mqcdn.com/tiles/1.0.0/osm/" OSM_DESC="MapQuest OpenStreetMap Worldwide Street Maps" \

	 OSM_FILE_EXT="png" OSM_NUM_ZOOM_LEVELS="19" ADDRESS="77 Water St, HALLOWELL, ME" RADIUS="5" \

	 CENTER_LABEL="Blue Marble Geographics" CENTER_LABEL_POS="-69.7908786,44.2859022"

IMPORT_SPATIAL_DB

The IMPORT_SPATIAL_DB command allows the user to import spatial data from a spatial database. The database can be either a file-based spatial database or a connection-based spatial database.:

SAMPLES

IMPORT_SPATIAL_DB TYPE="POSTGIS" SDB_CONNECTION_NAME="PostGIS" \

 SDB_TABLE_NAME="public.canada" SDB_IMPORT_BOUNDS="-126.821609,26.773888,-106.597575,50.302504"

 IMPORT_SPATIAL_DB TYPE="ESRI_XML_WORKSPACE" SDB_CONNECTION_FILE="filename" \

 SDB_TABLE_NAME="tablename"

IMPORT_WMS

The IMPORT_WMS command imports a chunk of WMS or WMTS (tiled WMS) data, such as satellite imagery or topographic maps. The following parameters are supported by the command:

SAMPLE

Here is an example of an IMPORT_WMS command that pulls in NAIP imagery within 5 km of Blue Marble's headquarters:


IMPORT_WMS WMS_SERVER_URL="http://isse.cr.usgs.gov/arcgis/services/Combined/USGS_EDC_Ortho_NAIP/MapServer/WMSServer" \

	 WMS_SERVICE="WMS" WMS_LAYER="0" ADDRESS="397 WATER ST, GARDINER, ME" RADIUS="5" \

	 LAYER_DESC="NAIP Color Imagery for US (1m Resolution)"

JOIN_TABLE

The JOIN_TABLE command joins the attributes from a table file to the features of a loaded vector layer. The following parameters are supported by the command:

LAYER_LOOP_END

The LAYER_LOOP_END command ends a loop of commands over loaded layers. See the LAYER_LOOP_START command for details.

LAYER_LOOP_START

The LAYER_LOOP_START command begins a loop of commands over load layers. You can loop over all layers or just those matching a particular filename mask. You end a loop over the files in a folder using the LAYER_LOOP_END command. Note that it is also possible to nest loops.

Built-in Variables

For any commands found within a LAYER_LOOP_START...LAYER_LOOP_END pair defining a loop, the following special character sequences (the LAYER part can be changed using the VAR_NAME_PREFIX parameter) can be used anywhere (examples of what the values will be based on a current layer filename of 'C:\data\my_file.dem' are listed):

The following parameters are used by the LAYER_LOOP_START command.

SAMPLE


GLOBAL_MAPPER_SCRIPT VERSION="1.00"

// Hide all layers

LAYER_LOOP_START FILENAME="*" VAR_NAME_PREFIX="HIDE"

    SET_LAYER_OPTIONS FILENAME="%HIDE_FNAME_W_DIR%" HIDDEN=YES

LAYER_LOOP_END

// Loop over the loaded layers, doing a separate export for each

LAYER_LOOP_START FILENAME="*"    

    // Enable the current layer since we hid it above

    SET_LAYER_OPTIONS FILENAME="%LAYER_FNAME_W_DIR%" HIDDEN=NO

    

    // Export

    EXPORT_RASTER FILENAME="%LAYER_DIR%%LAYER_FNAME_WO_EXT%_loop.tif" FORMAT=GEOTIFF

    

    // Disable the current layer so it won't be involved in other operations

    SET_LAYER_OPTIONS FILENAME="%LAYER_FNAME_W_DIR%" HIDDEN=YES

LAYER_LOOP_END

// Unhide all layers

LAYER_LOOP_START FILENAME="*" VAR_NAME_PREFIX="HIDE"

    SET_LAYER_OPTIONS FILENAME="%HIDE_FNAME_W_DIR%" HIDDEN=NO

LAYER_LOOP_END

LIDAR_CLASSIFY

The LIDAR_CLASSIFY command allows for automatically identifying and classifying ground-shot or building/high vegetation points from Lidar point clouds. The following parameters are supported by the command:

Ground Point Classification Options

Non-Ground (Building/Tree) Point Classification Options

Powerline Point Classification Options

Noise Point Classification Options

LIDAR_COMPARE

The LIDAR_COMPARE command allows for comparing the elevations from loaded Lidar point clouds to loaded 3D control points. You can also adjust the Lidar points to match the control points. The following parameters are supported by the command:

Example:

LIDAR_COMPARE REPORT_FILENAME="%SCRIPT_FOLDER%report.csv" FIT_POINTS=YES

LIDAR_EXTRACT

The LIDAR_EXTRACT command allows for automatically extracting building outlines, tree points/outlines, and linear powerlines from classified Lidar point clouds. Building extraction requires classified building points, tree extraction requires classified high vegetation points, and powerline extraction requires classified powerline points. The following parameters are supported by the command:

Building Extraction Options 

Tree Extraction Options 

Powerline Extraction Options

LOAD_PROJECTION

The LOAD_PROJECTION command imports a projection from a PRJ file and makes it the current global projection. This projection will be used for all exports after this command until another LOAD_PROJECTION command is encountered to change the global projection. The following parameters are supported by the command (you would just use one of the below):

LOAD_STYLE_FILE

The LOAD_STYLE_FILE command load a Global Mapper Style (.gm_style) file containing style definitions for a list of types. You can optionally choose to have any types specified in the style file that aren't present in the running instance of Global Mapper to be added, providing a script way to add new custom types. The following parameters are supported by the command:

LOAD_TYPE_FILTER

The LOAD_TYPE_FILTER command is deprecated as of Global Mapper v16.0.5. The SET_OPT command now handles both loading type filters and other generic global options. See that command for the list of parameters. The LOAD_TYPE_FILTER command will still work, but you should switch over to SET_OPT.

LOG_MESSAGE

The LOG_MESSAGE command writes a string to the status window and any active log file. You can use the SET_LOG_FILE command to set the log file to save message to. The USER_FILENAME parameter of that command allows you to have LOG_MESSAGE text written to a different file than default script messages. You can include variables in the command string if you want to log their values. Everything on the line after the LOG_MESSAGE will be written. For example if you have a variable named WATER_LEVEL_FT, you could log its value and a timestamp at the front as follows:


LOG_MESSAGE %TIMESTAMP%: The current value of WATER_LEVEL_FT is %WATER_LEVEL_FT%

If you would like to log messages to the command line (if running a script passed on the command line), make sure to include LOG_TO_COMMAND_PROMPT=YES in the GLOBAL_MAPPER_SCRIPT header line at the start of the script.

Other built-in variables (see DEFINE_VAR) allow you to log the elapsed time (in seconds) for a script. For example you can log the time for an import and export and total script time using the following:


GLOBAL_MAPPER_SCRIPT VERSION=1.00

LOG_MESSAGE Script <%SCRIPT_FILENAME%> started at %DATE% %TIME%

IMPORT FILENAME="test.tif"

LOG_MESSAGE Import took %TIME_SINCE_LAST_LOG%

EXPORT_RASTER TYPE=GEOTIFF FILENAME="output.tif"

LOG_MESSAGE Export took %TIME_SINCE_LAST_LOG%

LOG_MESSAGE Total Script Run Time: %TIME_SINCE_START%

MAP_LAYOUT

The MAP_LAYOUT command allows you to define the map layout settings to use for the map display, including margins, scale bar, legend, etc.

The MAP_LAYOUT command consists of a single command line followed by a series of lines with the contents of a .gm_layout file, like you would save from the Map Layout dialog. You can also provide a .gm_layout in the FILENAME parameter to just reference an external file rather than embedding the map layout directly in the script file.

The MAP_LAYOUT command is terminated with a single line containing only the text END_MAP_LAYOUT.

For a sample of the MAP_LAYOUT command in use, load some data, then save a Global Mapper workspace file from the File->Save Workspace menu command. Open the resulting .gmw file in an editor and you can see how the MAP_LAYOUT command is used at the bottom of the file to define the map layout.

The following parameters are required by the MAP_LAYOUT command.

PAN_SHARPEN

The PAN_SHARPEN command fuses a lower resolution color/multi-band image with a higher resolution panchromatic (grayscale) image to create a new color/multi-band image at the same detail as the pan image. This is often used with satellite-based imagery with a pan sensor at double the resolution as the color/multi-spectral sensor. The result is a new color/multi-band layer. In addition, all of the option parameters for the IMPORT command are also supported for this command.

The following parameters are used by the PAN_SHARPEN command:

SAMPLE

Example: Create a pan sharpened layer from 2 loaded 16-bit images:


// Define variables with filename for color and pan layers

DEFINE_VAR NAME="COLOR_FNAME" VALUE="LC80330322015307LGN00_B4325_RGBI"

DEFINE_VAR NAME="PAN_FNAME" VALUE="LC80330322015307LGN00_B8_PAN.TIF"

// Load color and pan layers

IMPORT FILENAME="%COLOR_FNAME%" TRANSPARENT_COLOR="RGB(255,255,255)" \

 AUTO_CONTRAST="YES" CONTRAST_SHARED="NO" CONTRAST_STRETCH_SIZE="2.000" CONTRAST_MODE="PERCENTAGE"

IMPORT FILENAME="%PAN_FNAME%" LOAD_FLAGS="0~0~0~1~0~0" TRANSPARENT_COLOR="RGB(0,0,0)" \

 AUTO_CONTRAST="YES" CONTRAST_SHARED="NO" CONTRAST_STRETCH_SIZE="0.000" CONTRAST_MODE="PERCENTAGE"

// Pan Sharpen images

PAN_SHARPEN COLOR_LAYER="%COLOR_FNAME%" PAN_LAYER="%PAN_FNAME%" ALGORITHM="BROVEY"



PLAY_SOUND

The PLAY_SOUND command plays either the information sound for the system or a specified sound file. This can be useful if you want audible confirmation when a script completes. The following parameters are supported by the command.

QUERY_LAYER_METADATA

The QUERY_LAYER_METDATA command allows a layer metadata value to be stored in a script variable. The user needs to identify the layer based on its file name (or layer description) and the metadata attribute based on the name it has when displayed via the Control Center. The following parameters are supported by this command:

SAMPLE

Example: Stores the layer's DESCRIPTION metadata in a variable called %DESC%:


DEFINE_VAR NAME="LAYER" VALUE="P:\Data\Areas.shp"

IMPORT FILENAME="%LAYER%" TYPE="SHAPEFILE"

QUERY_LAYER_METADATA METADATA_LAYER="%LAYER%" METADATA_ATTR="DESCRIPTION" RESULT_VAR="DESC"

RESTORE_LAST_SAVED_VIEW

The RESTORE_LAST_SAVED_VIEW command restores the last view saved with the SAVE_CURRENT_VIEW command (or the last view saved with the View->Save Current View menu command in the Global Mapper user interface). This command does not take any parameters.

RUN_COMMAND

The RUN_COMMAND command allows you to execute any program on Windows with a set of parameters. The following parameters are supported by the command.

SAMPLES

Here is a sample that runs another instance of Global Mapper and loads a file:


RUN_COMMAND COMMAND_LINE="'c:\program files (x86)\GlobalMapper16\global_mapper.exe' 'c:\temp\export test\blue_springs.opt'" WAIT_FOR_COMPLETE=NO

Here is a sample that calls another .exe and stores the return code of the .exe to the variable RESULT:


RUN_COMMAND COMMAND_LINE="'c:\temp\test1.exe'" CAPTURE_RESULT="RESULT"

SAVE_CURRENT_VIEW

The SAVE_CURRENT_VIEW command saves the current view window for later restoration using the RESTORE_LAST_SAVED_VIEW command. This command does not take any parameters.

SAVE_PROJECTION

The SAVE_PROJECTION command saves the current global projection to a PRJ file. The following parameters are supported by the command.

SAVE_WORKSPACE

The SAVE_WORKSPACE command saves any currently loaded layers to a workspace (GMW) file. The following parameters are supported by the command.

SET_BG_COLOR

The SET_BG_COLOR command sets the color to use for any background pixels when rendering layers. The following parameters are supported by the command.

SET_LAYER_OPTIONS

The SET_LAYER_OPTIONS command sets the display options for one of more loaded layers. These are the options that you would normally supply when importing a layer. The following parameters are supported by the command. In addition, all of the option parameters for the IMPORT command are also supported for this command.

SET_LOG_FILE

The SET_LOG_FILE command sets the name of the file to log status, warning, and error messages to. If the log file specified already exists, the messages will be appended to the end of it. The following parameters are supported by the command.

SET_OPT

The SET_OPT command provides a place to set general options that aren't layer-specific, like the Position Display Format (see POS_DISP_FORMAT below). Use the SET_VERT_DISP_OPTS command for options related to the display of terrain data. The functionality that used to be in the LOAD_TYPE_FILTER command is now found here as well. The following parameters are supported by the command:

Specifying a Type/Lidar Filter/ shared Lidar Draw Mode

SAMPLE

Example: Set an export option to snap to spacing, do an export, then restore the previous value


// Enable the option to snap to a spacing interval and save old value

SET_OPT MISC_OPT="EXPORT_BOUNDS_SNAP_SPACING" MISC_OPT_VALUE="1" MISC_OPT_OLD_VALUE_VAR="PREV_VAL_SPACING"

// Do the export

EXPORT_RASTER FILENAME="out.tif" TYPE=GEOTIFF

// Restore the old setting

SET_OPT MISC_OPT="EXPORT_BOUNDS_SNAP_SPACING" MISC_OPT_VALUE="%PREV_VAL_SPACING%"

SET_VERT_DISP_OPTS

The SET_VERT_DISP_OPTS command allows you to modify the options used when rendering elevation layers, such as the shader to use, if any, as well as the lighting and water setup. The following parameters are supported by this command:

SET_VIEW

The SET_VIEW command set the current view bounds. Use this in workspace files that run in the context of the main map view.

The following parameters are supported by the command:

SHIFT_LAYER

The SHIFT_LAYER command moves a layer by the specified offset.

The following parameters are supported by the command:

Example: Shift a layer by 500 meters in the X direction and 300 meters in the Y direction.


SHIFT_LAYER FILENAME="BackCove_base.tif" COORD_OFFSET="500,300" COORD_OFFSET_UNITS="M"

SHOW_3D_VIEW

The SHOW_3D_VIEW command displays the 3D view window with the loaded data.

The following parameters are supported by the command:

SORT_LAYERS

The SORT_LAYERS command allows you to sort the loaded layers based on some criteria, like name, resolution, type, etc. The following parameters are supported by the command:

SPLIT_LAYER

The SPLIT_LAYER command allows you to split a layer into multiple layers based on some attribute value. The original layer is closed if there was any split that happened.

The following parameters are supported by the command:

UNLOAD_ALL

The UNLOAD_ALL command unloads all currently loaded data. This command takes no parameters.

The following parameters are supported by the command:

UNLOAD_LAYER

The UNLOAD_LAYER command allows you to unload all previous loaded layers with a given filename. This is useful if you don't want to unload all previously loaded layers just to get rid of a few of them.

The following parameters are supported by the command:

VAR_LOOP_END

The VAR_LOOP_END command ends a loop of commands over a range of numeric values. See the VAR_LOOP_START command for details.

VAR_LOOP_START

The VAR_LOOP_START command begins a loop of commands over a range of numeric values or through a sequence of characters. This can be used as a simple counter or for more powerful things like custom gridding using coordinate values and naming exported files using the coordinates. Note that it is possible to nest loops and use different variable names for each loop to build complex filenames.

For any commands found within a VAR_LOOP_START...VAR_LOOP_END pair defining a loop, the current value of the loop variable will be available as a variable name. By default this will be %COUNTER%, but you can use the VAR_NAME parameter (see below) to make it whatever name that you want. By default some generic numeric formatting will be provided (i.e. whole numbers won't have a decimal or any leading 0's), but you can also provide custom formatting for the numeric value as a C-style format string like you would pass to a printf command using the VAL_FORMAT parameter (see below for details).

The following parameters are used by the VAR_LOOP_START command.

SAMPLE

Here is a simple example for looping over some rows and columns:


GLOBAL_MAPPER_SCRIPT VERSION=1.00

// Loop over rows 1-10 with leading zeroes in the format

VAR_LOOP_START VAL_START=1 VAL_STOP=10 VAL_STEP=1 VAL_FORMAT="%02d" VAR_NAME="%ROW%"

    // Loop over colums 5-15 in this row, use default formatting

	VAR_LOOP_START VAL_START=5 VAL_STOP=15 VAL_STEP=1 VAR_NAME="%COL%"

    

        // Import a file with the row and column in the filename

        IMPORT FILENAME="c:\path_to_file\base_filename_%ROW%_%COL%.jpg"

        

    VAR_LOOP_END

VAR_LOOP_END

VIEW_LAYOUT

The VIEW_LAYOUT command allows you to define the multi-view map layout defining where various map views are placed in the user interface.

The VIEW_LAYOUT command consists of a single command line followed by a series of lines with the contents of a .gm_views file, like you would save from the Map View Manager dialog. You can also provide a .gm_views in the FILENAME parameter to just reference an external file rather than embedding the map view layout definition directly in the script file.

The VIEW_LAYOUT command is terminated with a single line containing only the text END_VIEW_LAYOUT.

For a sample of the VIEW_LAYOUT command in use, set up the view layout you want using the Map View Manager, then save a Global Mapper workspace file from the File->Save Workspace menu command. Open the resulting .gmw file in an editor and you can see how the VIEW_LAYOUT command is used at the bottom of the file to define the map layout so long as you haven't disabled the save/restore of the multi-view layout to workspace files in the Advanced section of the General tab of the Configuration dialog.

The following parameters are required by the VIEW_LAYOUT command.

Attribute Name Parameter

An attribute name parameter has a value that can be either the name of an attribute or one of the special values below for accessing other fields associated with the feature:

Cropping Operations to Polygons/Areas

Most commands that support cropping can crop to a polygon using the POLYGON_CROP_FILE and related parameters. With these you can specify to crop the operation to area features from some vector file or already loaded layers. See below for a detailed description of the parameters that are related to polygon cropping:

EXAMPLE

GLOBAL_MAPPER_SCRIPT VERSION=1.00

EXPORT_RASTER FILENAME="C:\TEMP\" SPATIAL_RES="1, 1" TYPE=GEOTIFF\

POLYGON_CROP_FILE="ne_10m_admin_0_countries.shp" POLYGON_CROP_USE_EACH=YES POLYGON_CROP_NAME_ATTR="<Feature Name>" POLYGON_CROP_FILENAME_SUFFIX="_crop.tiff"

Gridding/Tiling Operations into Smaller Chunks

The following parameters apply to export and other commands that support breaking the operation up into regular tiles of some size rather than generating just a single output:

Built-in Variables

For any command that breaks up an operation in to multiple pieces using gridding, you can use one of the special character sequences below in a parameter of the command to use a piece of information about the grid cell being exported in the export (i.e. parts of grid cell filename). The examples of what the values will be based on a current grid filename of 'C:\path\to\my\data\my_file_A1.dem' are listed:

Projection Specification

A projection specification parameter has a value that can specify a projection in the following ways:

Specify Bounds for Operation

The following parameters apply to export and other commands that support providing a bounding box within which to perform the operation. You can also use the Polygon Crop Parameters for some operations rather than providing a bounding box. In most cases if no bounding box is provided the combined bounding box of all layers used for the operation will be used:

Lidar Advanced Filter Options

Lidar filter parameters can be applied to operations that process lidar data, including GENERATE_ELEV_GRID, EXPORT_VECTOR, LIDAR_CLASSIFY and LIDAR_EXTRACT

The available lidar filter parameters include:

Sample Scripts

Crop, Merge, and Reproject 4 USGS DRGs into new GeoTIFF and JPEG files

GLOBAL_MAPPER_SCRIPT VERSION=1.00

UNLOAD_ALL

// Import the four 24K DRGs that we want to merge. We use the CLIP_COLLAR option

// to indicate that we want the collar to be automatically removed from the

// DRGs when they are imported.

IMPORT FILENAME="C:\DATA\DRG\KANSAS CITY\O39094B2.TIF" \

 TYPE=AUTO ANTI_ALIAS=NO AUTO_CONTRAST=NO CLIP_COLLAR=AUTO TEXTURE_MAP=NO

IMPORT FILENAME="C:\DATA\DRG\KANSAS CITY\O39094A1.TIF" \

 TYPE=AUTO ANTI_ALIAS=NO AUTO_CONTRAST=NO CLIP_COLLAR=AUTO TEXTURE_MAP=NO

IMPORT FILENAME="C:\DATA\DRG\KANSAS CITY\O39094A2.TIF" \

 TYPE=AUTO ANTI_ALIAS=NO AUTO_CONTRAST=NO CLIP_COLLAR=AUTO TEXTURE_MAP=NO

IMPORT FILENAME="C:\DATA\DRG\KANSAS CITY\O39094B1.TIF" \

 TYPE=AUTO ANTI_ALIAS=NO AUTO_CONTRAST=NO CLIP_COLLAR=AUTO TEXTURE_MAP=NO

// Load a projection file to set the global projection to geographic (lat/lon)

// arc degrees with a datum of NAD83.

LOAD_PROJECTION FILENAME="C:\DATA\PRJ Files\geo_degrees_nad83.prj"

// Use the EXPORT_RASTER command to generate a new 8-bit per pixel GeoTIFF file

EXPORT_RASTER FILENAME="C:\DATA\EXPORTED DATA\merged_drg_8bpp.tif" \

 TYPE=GEOTIFF PALETTE=OPTIMIZED

// Now, use the EXPORT_RASTER command to generate a grayscale GeoTIFF file. Lets

// also create a world file for this one

EXPORT_RASTER FILENAME="C:\DATA\EXPORTED DATA\merged_drg_gray.tif" \

 TYPE=GEOTIFF PALETTE=GRAYSCALE GEN_WORLD_FILE=YES

// Create a JPEG file using the EXPORT_RASTER command. Also create a world file

// and a projection file to make it easier to load in other places.

EXPORT_RASTER FILENAME="C:\DATA\EXPORTED DATA\merged_drg.jpg"				\

 TYPE=JPEG GEN_WORLD_FILE=YES GEN_PRJ_FILE=YES

Generate Contours from all USGS DEMs in a Folder and Export them to DXF and Shape files

GLOBAL_MAPPER_SCRIPT VERSION=1.00

UNLOAD_ALL

// Loop over all DEM files in a folder and convert them

DIR_LOOP_START DIRECTORY="C:\DATA\SDTS_DEM\24K\" FILENAME_MASKS="*.DEM.STDS.TAR.GZ" RECURSE_DIR=NO

	// Import an archived SDTS DEM file. Global Mapper will automatically

	// determine that this is an archived SDTS DEM file and load it

	// correctly.

	IMPORT FILENAME="%FNAME_W_DIR%" ANTI_ALIAS=YES

	// Generate 50 ft contours from the loaded DEM data.

	GENERATE_CONTOURS INTERVAL=50 ELEV_UNITS=FEET

	// Export the contours to a new DXF file. The created file will have

	// 3D polyline features for the contours.

	EXPORT_VECTOR FILENAME="%DIR%%FNAME_WO_EXT%_CONTOURS.DXF" TYPE=DXF GEN_PRJ_FILE=YES

	// Export the contours to a 3D shape file.

	EXPORT_VECTOR FILENAME="%DIR%%FNAME_WO_EXT%_CONTOURS.SHP" TYPE=SHAPEFILE \

		SHAPE_TYPE=LINES GEN_3D_LINES=YES GEN_PRJ_FILE=YES

	// Unload the loaded data

	UNLOAD_ALL

// End the loop

DIR_LOOP_END

Edit Vector Features Based on an Attribute and Display Label

GLOBAL_MAPPER_SCRIPT VERSION=1.00

// Import the file to modify

IMPORT FILENAME="C:\Temp\export test\tiger_wyandotte_sample.gmp"

// Assign the type "railroad" to all features with a CFCC attribute with a value of A41

// and a display label with '74' in it somewhere.

EDIT_VECTOR LINE_TYPE="RAILROAD" COMPARE_STR="CFCC=A41" COMPARE_STR="<Feature Name>=*74*"

// Assign the name "Burlington Northern Railroad" to all features with a CFCC attribute with a value of A41

EDIT_VECTOR ATTR_VAL="<Feature Name>=Burlington Northern Railroad" COMPARE_STR="CFCC=A41"