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"

Normalize a Loaded Terrain Layer

GLOBAL_MAPPER_SCRIPT VERSION=1.00
// Query min and max values from metadata
QUERY_LAYER_METADATA METADATA_LAYER="SELECTED LAYERS" METADATA_ATTR="MIN ELEVATION" RESULT_VAR="MIN_unit"
QUERY_LAYER_METADATA METADATA_LAYER="SELECTED LAYERS" METADATA_ATTR="MAX ELEVATION" RESULT_VAR="MAX_unit"
//remove units from min and max values
DEFINE_VAR NAME="MIN" FORMULA="NUM('%MIN_unit%')"
DEFINE_VAR NAME="MAX" FORMULA="NUM('%MAX_unit%')"
//Normalize Terrain
APPLY_FORMULA LAYER_DESC="Normalized Terrain" FORMULA="(B1-%MIN%)/(%MAX%-%MIN%)*100" OUTPUT_GRID=YES

Autoclassify and export buildings from Lidar data in a folder

GLOBAL_MAPPER_SCRIPT VERSION=1.00
UNLOAD_ALL
DEFINE_VAR NAME="DATA_DIR" VALUE="%SCRIPT_FOLDER%"
SET_LOG_FILE FILENAME="%DATA_DIR%\log.txt" LOG_TO_COMMAND_PROMPT=YES

// Loop over all las files in a folder and classify them into ground points and non ground points
DIR_LOOP_START DIRECTORY="%DATA_DIR%\" FILENAME_MASKS="*.las" RECURSE_DIR=NO

// Import lidar data
IMPORT FILENAME="%FNAME_W_DIR%"

// Autoclassify ground points
LIDAR_CLASSIFY FILENAME=%FNAME% TYPE=GROUND

// Autoclassify non-ground points
LIDAR_CLASSIFY FILENAME=%FNAME% TYPE=NONGROUND LIDAR_RESET_NON_GROUND=YES LIDAR_MIN_HEIGHT="0.5" GRID_BIN_SIZE="-0.4"

// Extract buildings
LIDAR_EXTRACT FILENAME=%FNAME% GRID_BIN_SIZE="-0.6" TYPE=BUILDING LIDAR_PLANE_MAX_OFFSET="0.25" LIDAR_PLANE_MAX_ANGLE="25" SIMPLIFICATION="4"

// Unload just the currently loaded LIDAR file in the loop
UNLOAD_LAYER FILENAME=%FNAME%

// End the loop
DIR_LOOP_END

// Export the EXTRACTED buildings
EXPORT_VECTOR FILENAME="%DATA_DIR%\EXTRACTED__.shp" TYPE=SHAPEFILE SPLIT_BY_LAYER=YES SHAPE_TYPE="AREAS" GEN_PRJ_FILE=YES

Loop through a list of settings to Grid Lidar data

GLOBAL_MAPPER_SCRIPT VERSION=1.00

//load classified lidar data and check the option to 
//run script in context of main view to test this script
// Define table
DEFINE_VAR_TABLE NAME="SETTINGS" HAS_COL_NAMES=YES
   "name","grid_method","spacing","filter"
   "bareEarth",BIN_MIN,1,"2"
   "average",BIN_AVG,1,"ALL,-7,-18"
   "vegetationOnly",BIN_MAX,1,"NONE,2,5"
   "buildingsOnly",BIN_MAX,1,"NONE,2,6"
   "surface",BIN_MAX,1,"ALL,-7,-18"
END_VAR_TABLE

// Loop over files
VAR_LOOP_START VALUE_TABLE="SETTINGS" VAR_NAME="%GRID_layer%"
LOG_MESSAGE --Filename:%GRID_layer:name%
LOG_MESSAGE --Bin Method : %GRID_layer:grid_method%

GENERATE_ELEV_GRID GRID_ALG=%GRID_layer:grid_method% GRID_BIN_SIZE=%GRID_layer:spacing% LAYER_DESC=%GRID_layer:name% LIDAR_FILTER=%GRID_layer:filter%
VAR_LOOP_END

Export a set of Loaded Layers to Multiple Shapefiles

GLOBAL_MAPPER_SCRIPT VERSION="1.00"
LAYER_LOOP_START FILENAME="*" VAR_NAME_PREFIX="HIDE" SET_LAYER_OPTIONS FILENAME="%HIDE_FNAME_W_DIR%" HIDDEN=YES LAYER_LOOP_END LAYER_LOOP_START FILENAME="*" SET_LAYER_OPTIONS FILENAME="%LAYER_FNAME_W_DIR%" HIDDEN=NO EXPORT_VECTOR FILENAME="\output\%LAYER_DESC%.shp" TYPE=SHAPEFILE SHAPE_TYPE=LINES EXPORT_VECTOR FILENAME="\output\%LAYER_DESC%.shp" TYPE=SHAPEFILE SHAPE_TYPE=POINTS EXPORT_VECTOR FILENAME="\output\%LAYER_DESC%.shp" TYPE=SHAPEFILE SHAPE_TYPE=AREAS SET_LAYER_OPTIONS FILENAME="%LAYER_FNAME_W_DIR%" HIDDEN=YES LAYER_LOOP_END LAYER_LOOP_START FILENAME="*" VAR_NAME_PREFIX="HIDE" SET_LAYER_OPTIONS FILENAME="%HIDE_FNAME_W_DIR%" HIDDEN=NO LAYER_LOOP_END

Create Elevation Grids from a Directory of Lidar

GLOBAL_MAPPER_SCRIPT VERSION="1.00"
DIR_LOOP_START DIRECTORY="C:\temp\Lidar" FILENAME_MASKS=*las
IMPORT FILENAME=%FNAME_W_DIR% TYPE=LIDAR_LAS
GENERATE_ELEV_GRID FILENAME=%FNAME_W_DIR% ELEV_UNITS=METERS GRID_ALG=BIN_AVG
SET_VERT_DISP_OPTS ENABLE_HILL_SHADING=YES SHADER_NAME="Slope Shader"
EXPORT_RASTER FILENAME=C:\temp\Lidar\%FNAME_WO_EXT% TYPE=KML KML_RASTER_FORMAT=JPG
UNLOAD_ALL
DIR_LOOP_END

Classify a Folder of Lidar files as Ground and Buffer the Footprints

GLOBAL_MAPPER_SCRIPT VERSION=1.00
//log file filename
DEFINE_VAR NAME="LOGFILE_NAME" VALUE="Logfile.txt"

//Import LAS
DEFINE_VAR NAME="LASDIR" PROMPT="DIR" ABORT_ON_CANCEL="YES" PROMPT_TEXT="LAS directory" VALUE="%SCRIPT_FOLDER%"
DEFINE_VAR NAME="OUTDIR" VALUE="%LASDIR%CLASSIFIED"
SET_LOG_FILE USER_FILENAME="%OUTDIR%\%LOGFILE_NAME%"
LOG_MESSAGE 1- LiDAR control processing started at %DATE% %TIME%
LOG_MESSAGE
LOG_MESSAGE 2- Classifying ground points
LOG_MESSAGE

//Loop through all files in directory

DIR_LOOP_START DIRECTORY="%LASDIR%" FILENAME_MASKS="*.LAS" RECURSE_DIR=NO
IMPORT FILENAME="%FNAME_W_DIR%"
LOG_MESSAGE 3- Loaded %FNAME_W_DIR% : %DATE% %TIME%
//Reset all points to unclassified
EDIT_VECTOR FILENAME="%FNAME_W_DIR%" LIDAR_CLASS="0"
//Classify ground points
LIDAR_CLASSIFY FILENAME="%FNAME_W_DIR%" TYPE=GROUND LIDAR_RESET_GROUND="YES" GRID_BIN_SIZE="3.0" LIDAR_CURVATURE="0.1" LIDAR_SLOPE="75" LIDAR_MAX_HEIGHT_DELTA="10"
//Export layer
EXPORT_VECTOR EXPORT_LAYER="%FNAME_W_DIR%" TYPE="LIDAR_LAS" FILENAME="%OUTDIR%\%FNAME_WO_EXT%_classified.las"
//Close
UNLOAD_ALL
DIR_LOOP_END

//Buffer the CLIP File
DEFINE_VAR NAME="OUTDIR_CLIPPED" VALUE="%LASDIR%CLIPPED"
DEFINE_VAR NAME="CLIP_EXTENT" VALUE="%LASDIR%BOUNDARY"

DIR_LOOP_START DIRECTORY="%CLIP_EXTENT%" RECURSE_DIR=NO
IMPORT FILENAME="%FNAME_W_DIR%"
LOG_MESSAGE 696969369- CLIP EXTENT FILE TO BUFFER:"%FNAME_W_DIR%": %DATE% %TIME%
LOG_MESSAGE
DIR_LOOP_END
EDIT_VECTOR BUFFER_DIST="50.0"
EXPORT_VECTOR TYPE="KML" FILENAME="%CLIP_EXTENT%\%FNAME_W_DIR%_50mBUFFER.kml"

Keyword Link IconSearch Index