Create polygon bounding boxes of all files in a directory
George Chandeep Corea
Global Mapper UserTrusted User
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
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
-
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
Categories
- 12.7K All Categories
- 5.6K Features Discussion
- 342 Downloading Imagery
- 1.3K Elevation Data
- 380 Georeferencing Imagery Discussion
- 628 GM Script Language
- 53 User Scripts
- 113 GPS Features
- 414 Projection Questions
- 819 Raster Data
- 1.3K Vector Data
- 6.6K Support
- 177 Announcement and News
- 908 Bug Report
- 558 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 562 Other Discussion
- 129 GIS Data Sources
- 27 Global Mapper Showcase
- 233 How I use Global Mapper
- 107 Global Mapper Forum Website