insert all tables in calculate value tool model builder

658
4
Jump to solution
09-01-2022 02:05 AM
Labels (2)
VasudhaChaturvedi
New Contributor II
 

I cannot figure out how to insert all the dbf files for the code block in calculate value tool. After iterating through all files I use the expression below to get the two coefficient values in each dbf file and store them as two seperate coefficient value variable. I will then insert these values one dbf file at a time in raster calculator and multiple by a raster to generate interpolation maps. 

Expression: values[0]

Code block:for dbf_file in '%Iterate through tables and collect all dbf files%':
with arcpy.da.SearchCursor(dbf_file,["Coef"]) as cursor:
values = sorted({row[0] for row in cursor})

VasudhaChaturvedi_0-1662023376249.pngVasudhaChaturvedi_1-1662024811179.png

 

I have also tried it with python but I get an error. 

VasudhaChaturvedi_0-1662024613544.png

 

Can anyone help me out figuring out a way to attain my goal. 

Thank you.

 

0 Kudos
1 Solution

Accepted Solutions
VasudhaChaturvedi
New Contributor II

The answer to this question was just use copy tool and rename the files using the name variable from the iterate tables itself. I have further simplified the model.

VasudhaChaturvedi_0-1662390887230.png

 

VasudhaChaturvedi_1-1662390910253.png

 

View solution in original post

0 Kudos
4 Replies
VasudhaChaturvedi
New Contributor II

I have solved the issue of itering through dbf files, getting the two coefficient values in each file and inserting the two values in raster calculator.The following is the procedure:

1- Creating a sub model for iterating through tables,

VasudhaChaturvedi_0-1662035124463.png

2- creating a sub model to get both the coefficient values and add the sub model to the iterate dbf files model as shown in previous image,

VasudhaChaturvedi_3-1662035230264.png

 

3- Create two sub models for iterating through both list of coefficient values,

VasudhaChaturvedi_4-1662035253807.png

 

4- Lastly, create a final model with the raster calculator using the last two sub model where we itertae through the list of both coefficient values.

VasudhaChaturvedi_5-1662035275109.png

 

The challange I face now is how to iterate through the names of dbf files and use the names to save the interpolation rasters. The first model provides the names of rasters in the variable name but how I can insert these names in the last model with raster calculator. Is there a way?

VasudhaChaturvedi_0-1662035404644.png

 

0 Kudos
curtvprice
MVP Esteemed Contributor

You have the iteration backwards, the sub model should do the calculations (including raster calculator) and write the output, the driver (outside) model should do the iteration. See the examples in the help.

0 Kudos
VasudhaChaturvedi
New Contributor II

thank you helped a lot.

0 Kudos
VasudhaChaturvedi
New Contributor II

The answer to this question was just use copy tool and rename the files using the name variable from the iterate tables itself. I have further simplified the model.

VasudhaChaturvedi_0-1662390887230.png

 

VasudhaChaturvedi_1-1662390910253.png

 

0 Kudos