1

I have a simple python script that runs a Weighted Overlay process. This script runs fine locally but when I publish it to ArcGIS Server and submit the job through the REST service page, it gave me this error message:

ERROR 999999: Error executing function.
The name of the Field is invalid: valid names may contain letters, numbers or underscores.
Failed to execute (WeightedOverlay).

Then I found out that somehow ArcGIS Server changes the raster field name from "VALUE" (as specified in my script) to "Value". This is the message from ArcGIS Server when running the process:

Executing: WeightedOverlay "('D:\raster1' 50 'Value' (1 1;NODATA NODATA); 'D:\raster2' 50 'Value' (1 1; 2 1; 3 1; 4 1; 5 1; 6 1; 7 1;NODATA NODATA));1 9 1" ....

But the same script when run from ArcToolbox locally will return:

Executing: WeightedOverlay "('D:\raster1' 50 'VALUE' (1 1;NODATA NODATA); 'D:\raster2' 50 'VALUE' (1 1; 2 1; 3 1; 4 1; 5 1; 6 1; 7 1;NODATA NODATA));1 9 1" ....

I've restarted the ArcGIS Server service and also restarted the server as well, but no luck.

UPDATE:
Here is the code:

sRasterGLA = arcpy.GetParameterAsText(0)

lRasters = []
lRemapObjects = []
lWOTable = []
lOverlayMapping_11NN = [[1,1],["NODATA","NODATA"]]
lOverlayMapping_1NN1 = [[1,"NODATA"],["NODATA",1]]

remap_11NN = arcpy.sa.RemapValue(lOverlayMapping_11NN)
remap_1NN1 = arcpy.sa.RemapValue(lOverlayMapping_1NN1)

iTemp = 1
lRasters.append(sRasterMandatory)  # that's the directory path to the raster data
lRemapObjects.append(remap_11NN)

iTemp += 1
lRasters.append(sRasterGLA)
lRemapObjects.append(remap_1NN1)

iScale1 = int(100/iTemp)
iScale2 = 100 - iScale1 * iTemp
iParam1 = iScale1 + iScale2
iParam2 = iScale1

i = 0
while i < iTemp:
    if i == 0:
        lWOTable.append([lRasters[i], iParam1, "VALUE", lRemapObjects[i]])
    else:
        lWOTable.append([lRasters[i], iParam2, "VALUE", lRemapObjects[i]])
    i += 1

WOTableObj = arcpy.sa.WOTable(lWOTable, lOverlayScaleStep_191)
outWeightedOverlay = arcpy.sa.WeightedOverlay(WOTableObj)
sOutput = os.path.join(arcpy.env.scratchFolder, "WOTEST1")
outWeightedOverlay.save(sOutput)    
arcpy.SetParameterAsText(1, sOutput)
3
  • Mind showing the code? Nov 5, 2015 at 15:26
  • How do you handle input params? I don't see any arcpy.GetParameterAsText()... Nov 6, 2015 at 8:47
  • Missed putting those lines to get and set parameters in... Added those two lines in. Thanks for looking at this!!!
    – jma
    Nov 6, 2015 at 9:10

1 Answer 1

1

When publishing to ArcGIS Server, the script is consolidated so any workspace paths and some variables are altered so the data store can be used (see help for details).

This process is full of issues though and I've found that sometimes you just have to find the script on the server and edit it yourself. If you log on to the server, the script path will be something like D:\arcgisserver\directories\arcgissystem\arcgisinput\YourService.GPServer\extracted\v101_python\YourScript.py.

When you edit the script, you will see something like this at the top:

# Esri start of added variables
g_ESRI_variable_1 = os.path.join(arcpy.env.packageWorkspace,u'myconnection.sde')
g_ESRI_variable_2 = u'd:\\data\\globe20150804-134955.gdb'
g_ESRI_variable_3 = u'(!F_AREA!) / 1000000'
g_ESRI_variable_4 = u'F_AREA'
# Esri end of added variables

Then these variable names are substituted lower down:

INWorkspace = g_ESRI_variable_1

It sounds like the publisher is helpfully renaming "VALUE" to "Value", so you'll just have to edit the script to change it back.

Some of these publisher bugs are known issues, e.g. not using the data store, which is fixed at 10.3.

1
  • Unfortunately, this is not the case with my issue. The variable is still "VALUE" in the published script. It seems like ArcGIS Server is not recognizing the Spatial Analyst functions.
    – jma
    Nov 12, 2015 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.