EXPORT_RASTER results in empty PNG-files
OddBob
Global Mapper UserTrusted User
Hi!
I have a problem with a script in GM 14.2.4. This script loops through a folder looking for shape-files and exports them to corresponding Geo PNG files. The output files are very small and does not contain any colours as expected. When I try to run through all steps manually in the GM GUI for one of the files it works (open SHP-file, apply the styling file, export raster using palette file). The input shape files have attribute values for the attribute COLOR as specified in the layer style file, they are not empty. I've added the parameter INC_VECTOR_DATA=YES that might help according to other forum posts, but this did not help.
Below is the script and the corresponding layer and palette files.
Script:
GLOBAL_MAPPER_SCRIPT VERSION=1.00
UNLOAD_ALL
// Loop over all DEM files in a folder and convert them
DIR_LOOP_START DIRECTORY="D:\Incoming" FILENAME_MASKS="*.SHP" RECURSE_DIR=NO
IMPORT FILENAME="%FNAME_W_DIR%" TYPE=SHAPEFILE PROJ_EPSG_CODE=29902
LOAD_STYLE_FILE FILENAME="D:\Scripts\styles.gm_layer_style"
EXPORT_RASTER INC_VECTOR_DATA=YES FILENAME="%DIR%%FNAME_WO_EXT%.PNG" TYPE=PNG PALETTE="D:\Scripts\palette.pal" SPATIAL_RES=50.0,50.0 GEN_WORLD_FILE=YES
UNLOAD_ALL
// End the loop
DIR_LOOP_END
styles.gm_layer_style:
GM LAYER STYLE FILE
LayerStyle=2
Type=0
AttrName=COLOR
InterpolateNumeric=0
AttrVal=0 255 0
AttrAreaStyle=16711809,0,209,0,0.0
AttrFont=~0~534799372~0.000~0~0
AttrVal=255 0 0
AttrAreaStyle=4278190209,0,209,0,0.0
AttrFont=~0~534799372~0.000~0~0
palette.pal:
255,0,0
0,255,0
I have a problem with a script in GM 14.2.4. This script loops through a folder looking for shape-files and exports them to corresponding Geo PNG files. The output files are very small and does not contain any colours as expected. When I try to run through all steps manually in the GM GUI for one of the files it works (open SHP-file, apply the styling file, export raster using palette file). The input shape files have attribute values for the attribute COLOR as specified in the layer style file, they are not empty. I've added the parameter INC_VECTOR_DATA=YES that might help according to other forum posts, but this did not help.
Below is the script and the corresponding layer and palette files.
Script:
GLOBAL_MAPPER_SCRIPT VERSION=1.00
UNLOAD_ALL
// Loop over all DEM files in a folder and convert them
DIR_LOOP_START DIRECTORY="D:\Incoming" FILENAME_MASKS="*.SHP" RECURSE_DIR=NO
IMPORT FILENAME="%FNAME_W_DIR%" TYPE=SHAPEFILE PROJ_EPSG_CODE=29902
LOAD_STYLE_FILE FILENAME="D:\Scripts\styles.gm_layer_style"
EXPORT_RASTER INC_VECTOR_DATA=YES FILENAME="%DIR%%FNAME_WO_EXT%.PNG" TYPE=PNG PALETTE="D:\Scripts\palette.pal" SPATIAL_RES=50.0,50.0 GEN_WORLD_FILE=YES
UNLOAD_ALL
// End the loop
DIR_LOOP_END
styles.gm_layer_style:
GM LAYER STYLE FILE
LayerStyle=2
Type=0
AttrName=COLOR
InterpolateNumeric=0
AttrVal=0 255 0
AttrAreaStyle=16711809,0,209,0,0.0
AttrFont=~0~534799372~0.000~0~0
AttrVal=255 0 0
AttrAreaStyle=4278190209,0,209,0,0.0
AttrFont=~0~534799372~0.000~0~0
palette.pal:
255,0,0
0,255,0
Comments
-
The LOAD_STYLE_FILE command is designed for loading a style setup for the default types, but not applying it to a particular layer. What you need to do is embed the layer style in the script with a DEFINE_LAYER_STYLE command, then add an AREA_STYLE_NAME parameter to the IMPORT command that references it. This is not documented in the script reference, but to see how to do it just set up your styling in the UI, then save a workspace. You can see how this is done for layer-specific style setup in the .gmw file (also a script).
Let me know if I can be of further assistance.
Thanks,
Mike
Global Mapper Guru
geohelp@bluemarblegeo.com
Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation -
Thank you, Mike! Yes, this solved my problem.
I have previously in other scripts used the DEFINE_LAYER_STYLE embedded in the scripts. And forgot about this... Maybe it's a good idea to add some info reagarding this in the script reference. I do not see anything regarding AREA_STYLE_NAME for the IMPORT command.
My script will now look like this:
GLOBAL_MAPPER_SCRIPT VERSION=1.00
UNLOAD_ALL
/************ DEFINE LAYER STYLE *************/
DEFINE_LAYER_STYLE NAME="AREA_STYLE" TYPE="AREA"
LayerStyle=2
Type=0
AttrName=COLOR
InterpolateNumeric=0
AttrVal=0 255 0
AttrAreaStyle=16711809,0,209,0,0.0
AttrFont=~0~534799372~0.000~0~0
AttrVal=255 0 0
AttrAreaStyle=4278190209,0,209,0,0.0
AttrFont=~0~534799372~0.000~0~0
END_DEFINE_LAYER_STYLE
// Loop over all DEM files in a folder and convert them
DIR_LOOP_START DIRECTORY="D:\Incoming" FILENAME_MASKS="*.SHP" RECURSE_DIR=NO
IMPORT FILENAME="%FNAME_W_DIR%" TYPE=SHAPEFILE PROJ_EPSG_CODE=29902 AREA_STYLE_NAME="AREA_STYLE"
EXPORT_RASTER INC_VECTOR_DATA=YES FILENAME="%DIR%%FNAME_WO_EXT%.PNG" TYPE=PNG PALETTE="D:\Scripts\palette.pal" SPATIAL_RES=50.0,50.0 GEN_WORLD_FILE=YES
UNLOAD_ALL
// End the loop
DIR_LOOP_END
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