arcpy.sa.Spline issues in BETA2

3517
18
Jump to solution
02-27-2012 09:22 AM
BKuiper
Occasional Contributor III
the arcpy.sa.Spline function in BETA 2 has some issues:

- the %scratchworkspace% variable is not populated. The %scratchworkspace% value is not replaced with the actual location of your scratchworkspace.
- A temporary file is created (spline_selecXX) in the parent directory of the specified input file.

Not sure if the later can be really considered a bug, but i was surprised to see this behavior.

Can you confirm these issues ? I can send you an example, but this should be really easy to replicate.

ps: I'm running arcpy.sa.Spline through a python script, in ArcCatalog.
0 Kudos
18 Replies
BKuiper
Occasional Contributor III
Great, thanks for the feedback. I love what Esri does on these forums.
0 Kudos
BKuiper
Occasional Contributor III
Ok, next step. Now i'm trying to run my GPK, Geoprocessing Package, within ArcGIS Runtime, but it fails with the following error:

description=ERROR 000856: An error was encountered while executing Spline.
Failed to execute (Spline).

It works correctly within ArcMap and/or ArcCatalog.

First of all, an error message like that is not really helpful:

000856 : An error was encountered while executing <value>.
Resource Center
Description
There was a problem encountered while executing the specified tool. There are several possible causes for this situation, so you might need to investigate several possibilities to resolve it.
Solution
Check that the syntax is correct, the input datasets exist as specified and are valid, and that you are able to write to the output location.
Ensure that you have sufficient resources on your machine to complete the process.
Check the documentation for any notes or usage tips that may apply.
Contact technical support for assistance if you still cannot resolve the problem.


I thought it might be a license issue, so i used the Local Runtime License Viewer to generate my "Testing C#, Spatial Extension license" and copy/paste that into my app. This didn't change anything.

Any idea on what could be the problem ? The input file exists. Could it be that Spline is not supported correctly although the BETA 2 documentation suggests it is ?

this is against BETA 2.
0 Kudos
BKuiper
Occasional Contributor III
Here is the code that i use against the selection file that was already supplied in this thread.

# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# SplineExampleScript.py
# Created on: 2012-03-01 14:43:43.00000
#   (generated by ArcGIS/ModelBuilder)
# Usage: SplineExampleScript <selection0> <Z_value_field> <Spline_sele37> 
# Description: 
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy, os

# Check out any necessary licenses
arcpy.CheckOutExtension("spatial")

# Script arguments
selection0 = arcpy.GetParameterAsText(0)
if selection0 == '#' or not selection0:
    selection0 = "selection0" # provide a default value if unspecified

Z_value_field = arcpy.GetParameterAsText(1)
if Z_value_field == '#' or not Z_value_field:
    Z_value_field = "inmval" # provide a default value if unspecified

# overwrite existing files
arcpy.gp.overwriteOutput = 1


# Local variables:
Spline_sele37 = os.path.join(arcpy.env.scratchWorkspace, "scratch.gdb\\result")

# Process: Spline
try:
    arcpy.gp.Spline_sa(selection0, "inmval", Spline_sele37)
except Exception as e:
    msgs = arcpy.GetMessages(2)
    arcpy.AddError(msgs)
    arcpy.AddError(e.message)
    sys.exit()

arcpy.SetParameter(2, Spline_sele37)


Attached is the Spline.gpk
0 Kudos
BKuiper
Occasional Contributor III
Can somebody at Esri confirm this issue with the SA Spline method ?
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
Hi,

Unfortunately I have not been able to successfully test your Spline script example but I can confirm that the Spline tool (Spatial Analyst > Interpolation) is a supported tool and has been successfully tested.

Cheers

Mike
0 Kudos
BKuiper
Occasional Contributor III
Attached is an complete example that shows it is not working on ArcGIS Runtime BETA 2.

So, to summarize, it works as a Python script in ArcCatalog but as soon as it is packaged and run through Runtime I get the following error:


error:

Submitted.
Executing...
Executing (Script): Script C:\..\PoCSplineRuntime\shapefile\selection\selection0.shp
Start Time: Thu Mar 08 10:21:23 2012
Executing (Script): Script C:\..\PoCSplineRuntime\shapefile\selection\selection0.shp
Start Time: Thu Mar 08 10:21:23 2012
Executing (Script): Script C:\..\PoCSplineRuntime\shapefile\selection\selection0.shp
Start Time: Thu Mar 08 10:21:23 2012
Running script Script...
Workspace: c:\users\..\appdata\local\temp\arcgisruntime_7212\script\jobs\script_gpserver\jb9264a9300464798a84f4c3ef0b687d3\scratch
Output file: c:\users\..\appdata\local\temp\arcgisruntime_7212\script\jobs\script_gpserver\jb9264a9300464798a84f4c3ef0b687d3\scratch\result
ERROR 000856: An error was encountered while executing Spline.
Failed to execute (Spline).
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
Hi,

Sorry for the delay in getting back to you on this. Thanks for the excellent reproducer. I have tested with the latest ArcGIS Runtime local server and the latest WPF client assemblies and (without modification) your app produces the output below and [I think] a valid spline result (see attached screenshot of the result back in ArcMap). I believe this indicates you should be able to retest successfully in pre-release. You may just need to play around with the script to get the right output parameter (GPRasterData / GPDataFile) - or better would be a map server result which would then allow you to add the raster directly to the map as a dynamic map service layer. Alternatively, the dynamic layers functionality you were testing previously could be used to dynamically add rasters to an existing map service at runtime.

Submitted.
Executing...
Executing (Script): Script C:\WORK\PROJECTS\ArcGISRuntimeCRs\SplineTest\PoCSplineRuntime\shapefile\selection\selection0.shp
Start Time: Tue Mar 13 14:54:47 2012
Executing (Script): Script C:\WORK\PROJECTS\ArcGISRuntimeCRs\SplineTest\PoCSplineRuntime\shapefile\selection\selection0.shp
Start Time: Tue Mar 13 14:54:47 2012
Executing (Script): Script C:\WORK\PROJECTS\ArcGISRuntimeCRs\SplineTest\PoCSplineRuntime\shapefile\selection\selection0.shp
Start Time: Tue Mar 13 14:54:47 2012
Running script Script...
Workspace: c:\users\mbrans~1\appdata\local\temp\arcgisruntime_5020\script\jobs\script_gpserver\j38850bacf654422babed8dc177344f58\scratch
Output file: c:\users\mbrans~1\appdata\local\temp\arcgisruntime_5020\script\jobs\script_gpserver\j38850bacf654422babed8dc177344f58\scratch\result
Completed script Script...
Succeeded at Tue Mar 13 14:54:48 2012 (Elapsed Time: 1.00 seconds)
Succeeded at Tue Mar 13 14:54:48 2012 (Elapsed Time: 1.00 seconds)
Succeeded at Tue Mar 13 14:54:48 2012 (Elapsed Time: 1.00 seconds)
Invalid return value: c:\users\mbrans~1\appdata\local\temp\arcgisruntime_5020\script\jobs\script_gpserver\j38850bacf654422babed8dc177344f58\scratch\result
Failed.


Cheers

Mike
0 Kudos
BKuiper
Occasional Contributor III
Thanks. looking forward to ArcGIS Runtime Prerelease.
0 Kudos
SusanJones
Occasional Contributor II
Howzit All,

Has anyone got a solution for ArcGIS Server 10.1 to this issue?

We have a similar situation

Geoprocssing Overview:
- create a Feature Layer from a sql expression
- generate Kernel Density Layer
- set Layer into resulting Dynamic Map Service Layer as a Raster Layer

If the feature layer returns no records, then no result is returned and the GP Service fails because it cannot add the "Invalid" null result to the map.

Setting arcpy.SetSeverityLevel(0) ensures the task completes.

I think the problem occurs at the map services level because the task completes.

Susan

North South GIS
Auckland, New Zealand
0 Kudos