Batch clip by polygon attribute
RockWare
Global Mapper User
If I have a set of 4 geotiffs for example (named 1.tif, 2.tif, etc.) and I have a multi-polygon boundary shapefile with an attribute field containing the filenames (1.tif, 2,.tif, etc.). Can I batch clip the tifs using this file in a .gms file? I've attempted to use the POLYGON_CROP_USE_EACH parameter with little success. It seems to decide the best fit record on its own. Clipping based on an attribute field would be great if it doesn't already exist. If it does can someone post a simple .gms example. Cheers!
Comments
-
Currently the crop would choose whichever area most overlaps the input data, there isn't an option to export based on a match in input filename since each export could potentially have several inputs. However what you could do is the following:
1) IMPORT your polygon Shapefile
2) Use EXPORT_VECTOR with SPLIT_BY_ATTR to split into a separate file for each value of the attribute that matches the TIFF name
3) Use DIR_LOOP_START...DIR_LOOP_END loop to loop over each TIFF, then for the POLYGON_CROP_FILENAME use the name of the specified SHP that just contains the crop to use. You can use the %FNAME_WO_EXT% variable to get the based name (like '1') and append the .shp (like %FNAME_WO_EXT%.shp).
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 -
Thanks for the quick response Mike! Yeah, I was kind of hoping to avoid the split by attribute because I have a single feature class with 80,000 polygons...a lot of shapefiles to export! Glad to know that this is the best solution for now. Maybe something to consider in the next build. Thanks again!
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