I need to clip a large number of scanned historical aerials by an engineering grid. So scan A-1 needs to be clipped by the selection of the A-1 grid from the engineering grid. I know how to batch all the images from one grid, but how do I (can I?) batch

1188
4
07-06-2016 07:41 AM
NancyRoss
New Contributor

I need to clip a large number of scanned historical aerials by an engineering grid.  For instance scan L-28 needs to be clipped by the selection of the L-28 grid from the engineering grid polygon layer.  I know how to batch all the images from one grid, but how do I (can I?) batch each images from the corresponding selected polygon?

0 Kudos
4 Replies
DuncanHornby
MVP Frequent Contributor

It's sounds like all you need to do is create a model with a feature selection iterator, grouping by ID, this would create a temporary in memory layer of that single polygon which would feed into a clip tool. Looking at your uploaded image I am guessing that the rasters you are showing are separate files and it is not 1 big image? You would use inline substitution to create the paths to the raster files. Don't know what that is, then you need to read the help file.

The basic model would be something very similar to below:

Export Graphic.png

AlexSukupcak
New Contributor

Has anyone figured out how to go about creating the path to the input raster files?

0 Kudos
PavanYadav
Occasional Contributor II

Alex Sukupcak

See if the following works for you:

import arcpy
import os

rasters = []
workspace = r"D:\test\Stowe.gdb"
walk = arcpy.da.Walk(workspace, datatype="RasterDataset")

for dirpath, dirnames, filenames in walk:
    for filename in filenames:
        print(filename)
        rasters.append(os.path.join(dirpath, filename))

   

AlexSukupcak
New Contributor

Thank you, Pavan! That short script worked.

0 Kudos