Global Mapper v25.0

Help me, it's my first time!

hairama
hairama Global Mapper User
edited February 2014 in GM Script Language
I've been using Global Mapper for several months now, and it's great for my purposes. But... it's time for me to stop doing tedious, repetitive tasks and learn to script. But I've never scripted anything before and it's not working yet.

Here's what I need to do:

1. I need to take several months worth of weekly images from the same geographic location.
2. Load them in a work-space--they should already be geo-refrenced.
3. Crop them using a kind of shapefile that I created with the feature tool
4. Export the cropped images to a directory as separate GEOTIFF files--perhaps with their original names intact.

Since this is too hard for me, I decided to just try importing an image and exporting it, but I can't even get that to work. It says that it has exported the tiff, but the files don't appear in the directory. Can someone help me? Here's my code:
GLOBAL_MAPPER_SCRIPT VERSION=1.00

IMPORT FILENAME="y:\script_test\test.tif" \
TYPE=AUTO ANTI_ALIAS=NO AUTO_CONTRAST=NO CLIP_COLLAR=AUTO TEXTURE_MAP=NO


EXPORT_RASTER FILENAME="y:\script_test\result.tif" \
TYPE=GEOTIFF PALETTE=OPTIMIZED GEN_WORLD_FILE=NO


EXPORT_RASTER FILENAME="y:\script_test\result-grey.tif" \
TYPE=GEOTIFF PALETTE=GRAYSCALE GEN_WORLD_FILE=YES

What am I doing wrong?

Thanks for your help and consideration!

Comments

  • global_mapper
    global_mapper Administrator
    edited February 2014
    That script actually looks pretty good, if you use the File->Run Script menu command to run the script does the log of what happened provide any clues as to what may be wrong?

    For your actual goal you probably want to use the DIR_LOOP_START...DIR_LOOP_END commands to loop over your input files, then have a loop that looks something like the following:

    DIR_LOOP_START DIRECTORY="Y:\script_test\" FILENAME_MASKS="*.tif"

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

    // Export to a new file cropped to a Shapefile
    EXPORT_RASTER FILENAME="%DIR%%FNAME_WO_EXT%_cropped.tif" TYPE=GEOTIFF \
    PALETTE=OPTIMIZED GEN_WORLD_FILE=NO POLYGON_CROP_FILE="path_to_crop_shape_here"

    // Unload layers
    UNLOAD_ALL

    DIR_LOOP_END

    Thanks,

    Mike
    Global Mapper Guru
    geohelp@bluemarblegeo.com
    Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation
  • hairama
    hairama Global Mapper User
    edited February 2014
    Part of the problem was that I was writing to a network drive, and the permissions weren't working (I think.) But after I played around to get the settings I wanted, this worked great. Thanks for the code you suggested too, you saved me a lot of time!
    That script actually looks pretty good, if you use the File->Run Script menu command to run the script does the log of what happened provide any clues as to what may be wrong?

    For your actual goal you probably want to use the DIR_LOOP_START...DIR_LOOP_END commands to loop over your input files, then have a loop that looks something like the following:

    DIR_LOOP_START DIRECTORY="Y:\script_test\" FILENAME_MASKS="*.tif"

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

    // Export to a new file cropped to a Shapefile
    EXPORT_RASTER FILENAME="%DIR%%FNAME_WO_EXT%_cropped.tif" TYPE=GEOTIFF \
    PALETTE=OPTIMIZED GEN_WORLD_FILE=NO POLYGON_CROP_FILE="path_to_crop_shape_here"

    // Unload layers
    UNLOAD_ALL

    DIR_LOOP_END

    Thanks,

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