Hi Everyone,
I am trying to do a Weighted Overlay Analysis on three raster layers for some Suitability Analysis.
I am facing problem in passing Weighted Overlay Table as a parameter in gp Service for specifying dynamic Influence % for different layers.
I am able to mark weighted overlay table as parameter in Model Builder, which is running fine in Arcgis Desktop
but When I publish gp service, the parameter value is coming as constant (Snap attached), how can it be changed to "user defined ?
Also let me know if there is any other way of passing the Influence % to Weighted Overlay Table in gp service ?
I am also facing this problem...Please answer if someone knows the solution.
Sorry -- value tables are not supported as GP service parameters. The only away around this is to set up parameters of supported type that that can be then converted to a value table within your script or model.
Within ModelBuilder, you could use the Calculate Value tool convert those inputs to a string representation of the value table required by the Weighted Overlay tool and return that as type Value Table. The format of the string representation can be tricky, but it is (kind-of) visible in your screenshot, and you can also see it by running the tool in ArcMap and using Copy As Python Snippet in the Geoprocessing Results window.
Value Tables are non-transportable, and their Input mode will be fixed to Constant value in the Service Editor.
If you need your client to enter values rather than using the constant value, you'll need to modify your model or script so that it uses other data types besides Value Table
Input modes and parameter data types—Documentation (10.3 and 10.3.1) | ArcGIS for Server
Thanks a lot Curitce Price for your reply .
How can i convert string to weighted overlay table using calculated value tool, Since I am newbie to python.
I am getting an error in return - My Code Block is
The Error is -
Pls help ..
Ramesh, your code block needs to be a function to return a value. You call that function in the expression, usually passing a model element value as a parameter. For datasets that is often a raw string (so any "\" in the paths are interpreted correctly).
As I said, the easiest way to get that string representation is to run the tool interactively and Copy As Python Snippet from the Results window.
I know this is kludgy but this is the way to pass unsupported parameter types like value tables to a GP service. This method of building your own string representations is a handy way to get ModelBuilder to work with tools whose parameter validation or environment setup isn't working for you in the ModelBuilder environment. For example: Re: Create fishnet in iterative model
The following example worked for me with ArcGIS 10.2.2.
Screen shot of tool interface:
Copy As Python Snippet (I did some line wrapping here though it's still legal Python):
arcpy.gp.WeightedOverlay_sa( "('C:/WorkSpace/xg' 100 'VALUE' (1 1;NODATA NODATA); " "'C:/WorkSpace/yg' 0 'VALUE' (1 1;NODATA NODATA)); " "1 9 1", "C:/WorkSpace/StepI_0601/Step_I_0601.gdb/Weighte_xg1" )
From the above this is my attempt at creating a Calculate Value expression. If this runs you can connect its output to the Weighted Overlay tool. I tried this in ModelBuilder and it does validate (the tool will run with this input). I had to be fanatical in matching the formatting from my Copy As Python Snippet!!
Expression:
CalcWOTable(r"%Input Raster 1%", %Weight 1%, r"%Input Raster 2%", %Weight 2%)
Code Block:
def CalcWOTable(raster1, wt1, raster2, wt2): remap_string = "(1 1;2 2;3 3;4 4;5 5;NODATA NODATA)" scale_string = "1 9 1" WO_Table1 = "'{}' {} 'VALUE' {}".format(raster1, wt1, remap_string) WO_Table2 = "'{}' {} 'VALUE' {}".format(raster2, wt2, remap_string) WO_Table = "({}; {}); {}".format(WO_Table1, WO_Table2, scale_string) return WO_Table
Data Type:
Weighted Overlay Table
Of course you could modify this to add a third input raster and weight, and pass the scale_string as a parameter, but I kept the example simple so it would match my test tool run.