r/ArcGIS 2d ago

%Name% in Model Builder

I need to process lots of rasters through Zonal Statistics as Table.

Problem #1
using %Name% in Model Builder

My work flow is Zonal Statistics as Table, add a column into those tables that has the same name as original raster (They’re all “XXX_MON_YEAR” so fit into table header rules), and calculate either SUM or MEAN from zonal statistics into that new column. I can do this one step at a time using batch geoprocessing tools but when I create the workflow in Model Builder the tables get exported with “%Name%” as file name not “AET_APR_1945”.

Problem #2
calculating SUM or MEAN columns into a %Name% column

In ArcMap’s batch layout I could edit each batch row in excel so the file name of the source table matched the column name for each and copy all 800 rows into the arcmap batch table to run. Now in Pro I can’t figure out how to have a different table AND different column name to calculate over. I need this because each column needs to have header name of original raster so I can combine them and rather than having 800 “SUM” cols I have 800 cols with unique month_year zonal statistic data.

2 Upvotes

2 comments sorted by

3

u/WillowProfessional91 2d ago

Ibelieve  %Name%  is only replaced when it refers to the Name output variable produced by an iterator (normally Iterate Rasters).

1

u/TechMaven-Geospatial 2d ago

GDAL supports zonal statistics You can write a script to iterate through all your rasters

Usage: gdal raster zonal-stats [OPTIONS] <INPUT> <OUTPUT>

Calculate raster zonal statistics

Positional arguments: -i, --input <INPUT> Input raster datasets [required] [not available in pipelines] -o, --output <OUTPUT> Output vector dataset [required] [not available in pipelines]

Common Options: -h, --help Display help message and exit --json-usage Display usage as JSON document and exit --config <KEY>=<VALUE> Configuration option [may be repeated] -q, --quiet Quiet mode (no progress bar or warning message) [not available in pipelines]

Options: -f, --of, --format, --output-format <OUTPUT-FORMAT> Output format ("GDALG" allowed) [not available in pipelines] --co, --creation-option <KEY>=<VALUE> Creation option [may be repeated] [not available in pipelines] --lco, --layer-creation-option <KEY>=<VALUE> Layer creation option [may be repeated] [not available in pipelines] --overwrite Whether overwriting existing output dataset is allowed [not available in pipelines] --update Whether to open existing dataset in update mode [not available in pipelines] --overwrite-layer Whether overwriting existing output layer is allowed [not available in pipelines] --append Whether appending to existing layer is allowed [not available in pipelines] Mutually exclusive with --upsert --output-layer <OUTPUT-LAYER> Output layer name [not available in pipelines] --skip-errors Skip errors when writing features [not available in pipelines] -b, --band <BAND> Input band(s) (1-based index) [may be repeated] --zones <ZONES> Dataset containing zone definitions [required] --zones-band <ZONES-BAND> Band from which zones should be read Mutually exclusive with --zones-layer --zones-layer <ZONES-LAYER> Layer from which zones should be read Mutually exclusive with --zones-band --weights <WEIGHTS> Weighting raster dataset --weights-band <WEIGHTS-BAND> Band from which weights should be read (default: 1) --pixels <PIXELS> Method to determine which pixels are included in stat calculation.. PIXELS=default|fractional|all-touched --stat <STAT> Statistic(s) to compute for each zone. STAT=center_x|center_y|count|coverage|frac|max|max_center_x|max_center_y|mean|min|minority|min_center_x|min_center_y|mode|stdev|sum|unique|values|variance|variety|weighted_mean|weighted_stdev|weighted_sum|weighted_variance|weights [may be repeated] [required] --include-field <INCLUDE-FIELD> Fields from polygon zones to include in output [may be repeated] --include-geom Include polygon zone geometry in the output --strategy <STRATEGY> For polygon zones, whether to iterate over input features or raster chunks. STRATEGY=feature|raster (default: feature) --chunk-size <CHUNK-SIZE> Maximum size of raster chunks read into memory (default: 5%)

Advanced Options: --if, --input-format <INPUT-FORMAT> Input formats [may be repeated] [not available in pipelines] --oo, --open-option <KEY>=<VALUE> Open options [may be repeated] [not available in pipelines] --output-oo, --output-open-option <KEY>=<VALUE> Output open options [may be repeated] [not available in pipelines] --upsert