Global Mapper v25.0

Create polygon bounding boxes of all files in a directory

George Chandeep Corea
George Chandeep Corea Global Mapper UserTrusted User
edited September 2013 in GM Script Language
I want to write a script which will give me the polygon (bbox) of each file (raster and vector) in a directory and subdirectories...this is my first attempt at writing a gms.

GLOBAL_MAPPER_SCRIPT VERSION=1.00
UNLOAD_ALL


// Loop over all DEM files in a folder and convert them
DIR_LOOP_START DIRECTORY="X:\scratch\TRC_Symbology\TRC_SymbologyBase\Main Map" FILENAME_MASKS="*.*" RECURSE_DIR=NO
//is the above the best way to get it to open all files that GM can handle?


// Import files
IMPORT FILENAME="%FNAME_W_DIR%"


// Generate Boundary and name with _boundary
GENERATE_LAYER_BOUNDS="%FNAME_W_DIR%_boundary"
//I get a warning "Unknown command"

// If error then write error to text file with file name and error msg


// Unload the loaded data
UNLOAD_ALL


// End the loop
DIR_LOOP_END

I am using GM 14.2

Comments

  • global_mapper
    global_mapper Administrator
    edited September 2013
    You are close, first add PROMPT_IF_TYPE_UNKNOWN=NO to the IMPORT command so any file types that are unknown are just skipped rather than asking for format. Then change your command to generate bounds as follows:

    GENERATE_LAYER_BOUNDS FILENAME="%FNAME_W_DIR%" LAYER_DESC="%FNAME% - Boundary"

    You can change the LAYER_DESC as desired.

    Also change your UNLOAD_ALL to the following so you just unload the file and not the boundary:

    UNLOAD_LAYER FILENAME="%FNAME_W_DIR%"

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation