2

How do I use the Surface Volume tool in ArcMap via Model Builder, without using Python, to process a set of multiple float values in a loop, since an iterator takes integers when I implement a for loop?

See the attached image as indication.

enter image description here

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jul 19, 2020 at 18:56
0

3 Answers 3

3

An alternative method is to create a table and store your floats in that, 1 row per float value. Then use the Iterate Field Value iterator to drive your model. But I think @user2856 has the simplest solution.

answered Jul 19, 2020 at 22:59
3
  • the issue in here is that for both options, iterate multivalue and iterate field value it is not possible connect it to the so called "plane height" - which is the field of the tool i'd like apply multiple values to Commented Jul 21, 2020 at 15:09
  • 1
    Try parsing the output of the iterator into a Double using the Calculate Value tool, then feed that into the volume tool Commented Jul 21, 2020 at 18:59
  • Thanks, thats exactly what I was looking for! :) Commented Jul 22, 2020 at 7:45
3

You can use the Iterate Multivalue tool and add a list of floats:

enter image description here

answered Jul 19, 2020 at 23:09
0

Here is the code to loop the surface volume tool. You can hard-code the paths and run this in your favourite IDE. Or un-comment the arcpy.GetParameter....stuff and turn this into a Toolbox Tool.

try:
import sys, arcpy, traceback
arcpy.CheckOutExtension("3D")
arcpy.AddMessage( "Multi-Volumes for ArcGIS 10")
arcpy.AddMessage("Loop the 3D Analyist Surface Volume tools for a range of values...")
def GetValues(themessage, x):
 thevaluesatx = str(x)
 themessage = themessage.split("\n")
 thevalues = themessage[2].split(" ")
 for item in thevalues:
 thevalue = item.split("=")
 thevalue = thevalue[-1]
 thevaluesatx = thevaluesatx + "," + str(thevalue)
 thevaluesatx = thevaluesatx +"\n"
 arcpy.AddMessage(thevaluesatx)
 return thevaluesatx
My_txt = r"F:\FerndaleDirtPile20190729\ferndaledirtpipe20190729demUTMvolumes.csv"
My_surface= r"F:\FerndaleDirtPile20190729\ferndaledirtpipe20190729demUTM.tif"
direction = "ABOVE"
startingplane = 4
endingplane = 10.4
z = 1
graduations = 0.25
#My_surface= arcpy.GetParameterAsText(0)
#My_txt = arcpy.GetParameterAsText(1)
#direction = arcpy.GetParameterAsText(2)
#startingplane = float(arcpy.GetParameterAsText(3))
#z = float(arcpy.GetParameterAsText(4))
#graduations = float(arcpy.GetParameterAsText(5))
#endingplane = float(arcpy.GetParameterAsText(6))
direction = direction.upper()
f = open(My_txt,'a')
f.writelines(r"elevation, 2d_area, 3d_area, volume" + "\n")
arcpy.AddMessage("Please wait, this script is processing...")
if direction == "BELOW":
 arcpy.AddMessage("startingplane = " +str(startingplane))
 arcpy.AddMessage("endingplane = " +str(endingplane))
 
 while startingplane > endingplane:
 arcpy.AddMessage("Getting Results...")
 result = arcpy.SurfaceVolume_3d(My_surface, "", direction, startingplane)
 thevaluesatx = GetValues(result.getMessages(0), startingplane)
 f.writelines(thevaluesatx)
 
 startingplane = startingplane - graduations
if direction == "ABOVE":
 arcpy.AddMessage("Executing above...")
 x = startingplane
 while startingplane < endingplane:
 result = arcpy.SurfaceVolume_3d(My_surface, "", direction, startingplane, z)
 thevaluesatx = GetValues(result.getMessages(0), startingplane)
 print thevaluesatx
 f.writelines(thevaluesatx)
 
 startingplane = startingplane + graduations
f.close()
arcpy.AddMessage("Finished without errors!")
except arcpy.ExecuteError: 
 msgs = arcpy.GetMessages(2) 
 arcpy.AddError(msgs) 
 #If the error is with the script, or with python, find error and report it to the screen...
except:
 tb = sys.exc_info()[2]
 tbinfo = traceback.format_tb(tb)[0]
 pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
 msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
 arcpy.AddError(pymsg)
 arcpy.AddError(msgs)
Hornbydd
44.9k5 gold badges42 silver badges84 bronze badges
answered Jul 20, 2020 at 0:46
1
  • The question specifically states "without using Python". Commented Jul 20, 2020 at 3:16

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.