AnsweredAssumed Answered

Generating new output names after each iteration

Question asked by sam.roodbar on Dec 6, 2018
Latest reply on Dec 17, 2018 by sam.roodbar

Hello Everyone, 

I'm trying to write a script that will take a look at a list of county boundaries and then take each boundary and use it as a mask on a raster so that I can do Extract By Mask. Ideally I would like to have the county names on the output but I cannot figure out a way to do that, but any unique name at this point would do. Here is the script that I use:

>>> import os
>>> import arcpy
>>> from arcpy import env
>>> from import *
>>> env.workspace = "C:/Users/s/Desktop/S/test"
>>> inRaster = "escrec"
>>> counter = 1
>>> ctyList = arcpy.ListFeatureClasses ("*.shp")
>>> for shp in ctyList:
... out =,shp)
..."C:/Users/s/Desktop/test/out/masked"+ counter)
... counter = counter+2

I tried using this counter thing but it doesn't work due to concatenate issue (str and numbers). Anyone has any suggestions or tricks that they have done? I tried setting the counter as my "ctyList" but since feature have .shp it doesn't allow that to save.

extract by mask acrpy