Exporting to PNG not finding any loaded data.
sportzfrk
Banned User
Hi all,
This is my first time scripting in Global Mapper (using version 18) but I have been reading the scripting reference a lot. I thought I had this down but I still can't get a PNG to export at all.
I have about 12-18 layers in each workspace, most are vector data like outlines. I want to open up each workspace, select the correct layers, and export (either a DXF file or a PNG)
So I want in this example to only export all layers with the description that starts with "Outline". I've verified through logging that I'm hiding and unhiding the correct layers, but the export says that there is no loaded data. So I'm wondering if there is something I'm doing wrong in the EXPORT_RASTER command.
Code is below. Thanks for the help in advance,
Jake
GLOBAL_MAPPER_SCRIPT VERSION=1.0
// Clear out anything already loaded
UNLOAD_ALL
//Start loop
DIR_LOOP_START DIRECTORY="C:\Golf\Mapping\" FILENAME_MASKS="*.gmw" RECURSE_DIR=NO
// Embed the script
EMBED_SCRIPT FILENAME=%FNAME_W_DIR%
LAYER_LOOP_START FILENAME="*"
IF COMPARE_STR="%LAYER_DESC%=Outline*"
// Unhide all layers that start with Outline
SET_LAYER_OPTIONS FILENAME="%LAYER_FNAME_W_DIR%" HIDDEN=NO
ELSE
// Hide all other layers
SET_LAYER_OPTIONS FILENAME="%LAYER_FNAME_W_DIR%" HIDDEN=YES
END_IF
LAYER_LOOP_END
// Export PNG
EXPORT_RASTER FILENAME="C:\Golf\MappingOutput\%FNAME_WO_EXT%_raster.png" TYPE="PNG" \
EXPORT_LAYER="*" FORCE_SQUARE_PIXELS=YES GEN_WORLD_FILE=YES GEN_PRJ_FILE=YES \
BG_TRANSPARENT=YES INC_VECTOR_DATA=YES
UNLOAD_ALL
DIR_LOOP_END
This is my first time scripting in Global Mapper (using version 18) but I have been reading the scripting reference a lot. I thought I had this down but I still can't get a PNG to export at all.
I have about 12-18 layers in each workspace, most are vector data like outlines. I want to open up each workspace, select the correct layers, and export (either a DXF file or a PNG)
So I want in this example to only export all layers with the description that starts with "Outline". I've verified through logging that I'm hiding and unhiding the correct layers, but the export says that there is no loaded data. So I'm wondering if there is something I'm doing wrong in the EXPORT_RASTER command.
Code is below. Thanks for the help in advance,
Jake
GLOBAL_MAPPER_SCRIPT VERSION=1.0
// Clear out anything already loaded
UNLOAD_ALL
//Start loop
DIR_LOOP_START DIRECTORY="C:\Golf\Mapping\" FILENAME_MASKS="*.gmw" RECURSE_DIR=NO
// Embed the script
EMBED_SCRIPT FILENAME=%FNAME_W_DIR%
LAYER_LOOP_START FILENAME="*"
IF COMPARE_STR="%LAYER_DESC%=Outline*"
// Unhide all layers that start with Outline
SET_LAYER_OPTIONS FILENAME="%LAYER_FNAME_W_DIR%" HIDDEN=NO
ELSE
// Hide all other layers
SET_LAYER_OPTIONS FILENAME="%LAYER_FNAME_W_DIR%" HIDDEN=YES
END_IF
LAYER_LOOP_END
// Export PNG
EXPORT_RASTER FILENAME="C:\Golf\MappingOutput\%FNAME_WO_EXT%_raster.png" TYPE="PNG" \
EXPORT_LAYER="*" FORCE_SQUARE_PIXELS=YES GEN_WORLD_FILE=YES GEN_PRJ_FILE=YES \
BG_TRANSPARENT=YES INC_VECTOR_DATA=YES
UNLOAD_ALL
DIR_LOOP_END
Tagged:
Comments
-
Update:
The following script works if you check to run in the main view but will not work if it is unchecked. I really want to run this via command line, so without the main view would be ideal. Any idea why that's the case?
Reminder that most of these layers are Embedded overlays in the workspace so they don't have file names associated with them, so I have to work with the layer descriptions. Is that why it can only work in the context of the main view?
GLOBAL_MAPPER_SCRIPT VERSION=1.00
DIR_LOOP_START DIRECTORY="C:\GolfX\Mapping\" FILENAME_MASKS="*.gmw" RECURSE_DIR=NO
// Embed the script
EMBED_SCRIPT FILENAME=%FNAME_W_DIR%
// need to hide all layers
LAYER_LOOP_START FILENAME="*"
IF COMPARE_STR="%LAYER_DESC%=Outline*"
// Unhide all layers that start with Outline
SET_LAYER_OPTIONS FILENAME="%LAYER_DESC%" HIDDEN=NO
LOG_MESSAGE This layer starts with Outline
ELSE
// Hide all other layers
SET_LAYER_OPTIONS FILENAME="%LAYER_DESC%" HIDDEN=YES
LOG_MESSAGE This layer did NOT start with Outline and was hidden.
END_IF
LAYER_LOOP_END
// Export PNG
EXPORT_RASTER FILENAME="C:\GolfX\MappingOutput\%FNAME_WO_EXT%_raster.png" \
EXPORT_LAYER="*" TYPE="PNG" FORCE_SQUARE_PIXELS=YES GEN_WORLD_FILE=YES \
GEN_PRJ_FILE=YES BG_TRANSPARENT=YES
DIR_LOOP_END
Categories
- 12.8K All Categories
- 5.7K Features Discussion
- 346 Downloading Imagery
- 1.3K Elevation Data
- 385 Georeferencing Imagery Discussion
- 639 GM Script Language
- 54 User Scripts
- 115 GPS Features
- 417 Projection Questions
- 829 Raster Data
- 1.3K Vector Data
- 6.6K Support
- 178 Announcement and News
- 920 Bug Report
- 559 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 573 Other Discussion
- 131 GIS Data Sources
- 27 Global Mapper Showcase
- 241 How I use Global Mapper
- 108 Global Mapper Forum Website