Global Mapper v25.0

Batch clip by polygon attribute

RockWare
RockWare Global Mapper User
edited December 2013 in Raster Data
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

  • global_mapper
    global_mapper Administrator
    edited December 2013
    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
  • RockWare
    RockWare Global Mapper User
    edited December 2013
    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!