POST
|
So I understand that part. The only thing left to bring it all together is instead of using "c:/path/vffile.txt". - use a variable that is assigned for the file. So if we use your example, this is what I want it to look like(this doesn't work): import arcpy Toblers_table = arcpy.getParamter(0) vertical_factor = arcpy.sa.VfTable(Toblers_table) out_path_dist = arcpy.sa.PathDistance("source.shp", "costraster", "", "", "", "",vertical_factor) out_path_dist.save("C:/workspace/path_dist_by_vf.tif") I am not sure what function to use for the 2nd line of code. I have tried that^ and Toblers_table = arcpy.getParameterAsText(0) Toblers_table = UTILS.getTextParameter(0). I was also thinking if there was a function to get the path name of the file so I could just put that in the vertical factor section of the path distance tool. I am just trying to avoid having to code in the "c/apth/vfile.txt".
... View more
04-21-2015
03:40 PM
|
0
|
1
|
751
|
POST
|
I'm not actually sure how to get the print statement to work with a custom parameter. Cause PyScripter doesn't prompt for an input so the UTILS.getTextParameter(0) is useless without an ArcMap interface. Do you know how to run it? or do you want me to send you the toblers function .txt file I am trying to use?
... View more
04-20-2015
03:09 PM
|
0
|
0
|
751
|
POST
|
The example I put "TABLE Tobler_input" was just the last thing I tried so I figured just to put it as an example. I tried what you said with just the Tobler_input as the parameter but that also give a similar error where it says 'unable to open file' but has the variable as the file name instead of the files actual name. The funny thing is when I make the path distance tool in model builder with the same parameters and then export it to python script, it works and gives the result I want but what it puts for the vertical factor parameter is the entire path name with the TABLE word in front within quotes. It looks like this: "TABLE C:\\user\\folder\\folder\\Tobler_function.txt". I don't understand why it has TABLE in the quotes but it seems to be an issue when I try to use a variable like Tobler_input instead of the path name in quotes. It also may be worth noting that the custom input parameter UTILS.getTextParamer(0) may not be the one I want. Initially I was using arcpy.GetParameterAsText but after cross referencing a few other custom tools importing a .txt or table file, they all used UTILS.getTextParamer so I figured I would give it a shot. Any ideas on that?
... View more
04-17-2015
07:50 PM
|
0
|
2
|
751
|
POST
|
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)
... View more
04-17-2015
01:31 PM
|
0
|
7
|
4081
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|