AnsweredAssumed Answered

How to import a .txt into a custom python tool as a variable and use the variable as vertical factor of path distance tool

Question asked by schroea on Apr 17, 2015
Latest reply on Apr 21, 2015 by SWalbridge-esristaff

I am building a custom python tool in ArcMap 10.2.2 and one of the Input Variables needs to be Tobler's Hiking Function as a .txt which will be used as the Vertical Factor in the Path Distance tool. So the input Parameter(right-click the tool > properties > parameter tab) is Table and the interface allows me to select the .txt file just fine. I then have been trying to get the .txt into a variable using

Tobler_input = UTILS.getTextParamer(0) and then insert the variable into the path distance tool as a Table vertical factorbut it says "Unable to open file" and then gives the path location up to where the .txt file is located.

 

Here is basically what the code for that part is.

 

import arcpy

import SSUtilities as UTILS

from arcpy.sa import *

arcpy.CheckOutExtension("spatial")

#------------------------------------------------

Tobler_input = UTILS.getTextParamer(0)

 

arcpy.gp.PathDistance_sa(LKL_input, PathDist_output, LCover_aoi_reclass, DEM_aoi_1, "", "BINARY 1 45", DEM_aoi_2, "TABLE Tobler_input", "", Output_backlink_raster)

 

I am not sure what kind of syntax needs to go into the Vertical Factor parameter for it to recognize the variable that is the .txt file with Tobler's hiking function in it.

(the code works just fine if I hard code the .txt file location in the Vertical Factor parameter. ie: C:\\user\\folder\\folder\\Tober_function.txt)

Outcomes