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".
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. The only exception to this is the DEFINE_PROJ command. It has a slightly different format that is described later.
You can run a Global Mapper script file automatically be 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.
Any lines that being 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.
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 Worksapce 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.
The EMBED_SCRIPT command allows you to call another script from within a script. 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:
The EXPORT_ELEVATION command exports all currently loaded elevation data to a file. The following parameters are supported by the command.
The EXPORT_RASTER command exports all currently loaded raster, vector, and elevation data to a file. The following parameters are supported by the command.
The EXPORT_VECTOR command exports all currently loaded vector data to a file. The following parameters are supported by the command.
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.
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.
The GLOBAL_MAPPER_SCRIPT must be the first command in the file. The only parameter supported is the VERSION parameter. Currently, the entire command line should look like:
GLOBAL_MAPPER_SCRIPT VERSION=1.00
The IMPORT command imports a data file for later use. The following parameters are supported by the command.
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.
The IMPORT_ASCII command imports data from a generic ASCII text file for later use. The following parameters are supported by the command.
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
The IMPORT_TERRASERVER command imports a chunk of TerraServer data, such as satellite imagery or topographic maps. The following parameters are supported by the command:
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 spported by the command:
The SAVE_PROJECTION command saves the current global projection to a PRJ file. The following parameters are supported by the command.
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.
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.
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:
The SHOW_3D_VIEW command displays the 3D view window with the loaded data.
The following parameters are supported by the command:
The UNLOAD_ALL command unloads all currently loaded data. This command takes no parameters.
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:
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=YES TEXTURE_MAP=NO IMPORT FILENAME="C:\DATA\DRG\KANSAS CITY\O39094A1.TIF" \ TYPE=AUTO ANTI_ALIAS=NO AUTO_CONTRAST=NO CLIP_COLLAR=YES TEXTURE_MAP=NO IMPORT FILENAME="C:\DATA\DRG\KANSAS CITY\O39094A2.TIF" \ TYPE=AUTO ANTI_ALIAS=NO AUTO_CONTRAST=NO CLIP_COLLAR=YES TEXTURE_MAP=NO IMPORT FILENAME="C:\DATA\DRG\KANSAS CITY\O39094B1.TIF" \ TYPE=AUTO ANTI_ALIAS=NO AUTO_CONTRAST=NO CLIP_COLLAR=YES 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
GLOBAL_MAPPER_SCRIPT VERSION=1.00 UNLOAD_ALL // 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="C:\DATA\SDTS_DEM\24K\RED ROCK CANYON, CO - 30M.DEM.SDTS.TAR.GZ" 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="C:\DATA\EXPORTED DATA\CONTOURS.DXF" TYPE=DXF GEN_PRJ_FILE=YES // Export the contours to a 3D shape file. EXPORT_VECTOR FILENAME="C:\DATA\EXPORTED DATA\CONTOURS.SHP" TYPE=SHAPEFILE \ SHAPE_TYPE=LINES GEN_3D_LINES=YES GEN_PRJ_FILE=YES