Help me, it's my first time!
hairama
Global Mapper User
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:
What am I doing wrong?
Thanks for your help and consideration!
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
-
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 -
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!global_mapper wrote: »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
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