Iterating folder creation and clipping of rasters

925
4
10-05-2021 12:52 PM
CBars
by
New Contributor II

Hi Everyone,

First post here, but I was wondering if anyone had information on how to make a model that performs the following:

Background: Making a model that will pull a polygon of a town within a county from a set, make a folder with its name, clip a DEM raster of the county to the shape of the town with a specific name, and create a contour shapefile of the trimmed DEM

Iterating this process for each town within the county

Let me know of any thoughts! Thank you!

0 Kudos
4 Replies
DavidPike
MVP Frequent Contributor

should be fairly straightforward (appreciate it can be daunting at first).

Iterate Feature Selection (ModelBuilder)—ArcGIS Pro | Documentation

group by your town name, this will also become the 'Value' variable with which you will use inline variable substitution to name the folders and files.

Inline variable substitution—ArcGIS Pro | Documentation

next step - create a new folder, use the inline variable to set the folder name Create Folder (Data Management)—ArcGIS Pro | Documentation

Clip, or Extract by Mask tool.

Contour tool (use inline variable again to name your final output) also remember to use the new folder path from Create Folder as another inline variable.

CBars
by
New Contributor II

Got up to here but having further complication specifying which folder to send the cropped raster to, any ideas?

CBars_0-1633494705225.png

 

0 Kudos
DavidPike
MVP Frequent Contributor

I almost never use model builder unfortunately.  I did have a play however and got it to work, though it is convoluted and there's likely much better ways of doing it.

Use Parse Path (insert -> model builder tools -> parse path) and connect it to your Create Folder green output variable. parse path type = PATH

Rename the output variable from Parse Path to 'FilePath' (without the quotes)

You don't need to have Feature Class to Shapefile, you can just use the green output from Iterate Feature Selection as the clipping geometry for the Clip tool.  Obviously add the clip tool also.

connect FilePath variable you just renamed to the Clip tool, and set it as a Precondition only.

In your Clip tool properties, set the output filename as

%FilePath%\%Value%\DEM.tif

also be aware clip can be an intensive process, I would create a small test dataset over a small clipping area, maybe only 2 or 3 features(towns) to use initially.

0 Kudos
CBars
by
New Contributor II

Thanks so much!

0 Kudos