Result

摘要

通过地理处理工具返回 Result 对象。

讨论

Result 对象的优点是可以保留工具执行的相关信息,包括消息、参数和输出。即使在运行了多个其他工具后仍可保留这些结果。

语法

Result (toolname, resultID)
参数说明数据类型
toolname

The name of the executed tool.

String
resultID

The job ID.

Integer

属性

属性说明数据类型
inputCount
(只读)

Returns the number of inputs.

Integer
maxSeverity
(只读)

Returns the maximum severity of the message.

Integer
messageCount
(只读)

Returns the number of messages.

Integer
outputCount
(只读)

Returns the number of outputs.

Integer
resultID
(只读)

Gets the job ID. If the tool is not a geoprocessing service, the resultID will be "".

String
status
(只读)

Gets the job status.

  • 0New
  • 1Submitted
  • 2Waiting
  • 3Executing
  • 4Succeeded
  • 5Failed
  • 6Timed out
  • 7Cancelling
  • 8Cancelled
  • 9Deleting
  • 10Deleted
Integer

方法概述

方法说明
cancel ()

Cancels an associated job

getInput (index)

Returns a given input, either as a recordset or string.

getMapImageURL ({parameter_list}, {height}, {width}, {resolution})

Gets a map service image for a given output, if one exists.

getMessage (index)

Returns a specific message.

getMessages ({severity})

Returns messages.

getOutput (index)

Returns a given output, either as a recordset or string.

If the output of the tool, such as MakeFeatureLayer is a layer, getOutput will return a Layer object.

getSeverity (index)

Returns the severity of a specific message.

方法

cancel ()
getInput (index)
参数说明数据类型
index

The index position of the input.

Integer
返回值
数据类型说明
Object

The input, either as a recordset or string.

getMapImageURL ({parameter_list}, {height}, {width}, {resolution})
参数说明数据类型
parameter_list

Parameter(s) on which the map service image will be based.

Integer
height

The height of the image.

Double
width

The width of the image.

Double
resolution

The resolution of the image.

Double
返回值
数据类型说明
String

The URL of the map image.

getMessage (index)
参数说明数据类型
index

The index position of the message.

Integer
返回值
数据类型说明
String

The geoprocessing message.

getMessages ({severity})
参数说明数据类型
severity

The type of messages to be returned: 0=message, 1=warning, 2=error. Not specifying a value returns all message types.

  • 0informational message
  • 1warning message
  • 2error message

(默认值为 0)

Integer
返回值
数据类型说明
String

The geoprocessing messages.

getOutput (index)
参数说明数据类型
index

The index position of the outputs.

Integer
返回值
数据类型说明
Object

The output, either as a recordset or string.

If the output of the tool, such as MakeFeatureLayer is a layer, getOutput will return a Layer object.

getSeverity (index)
参数说明数据类型
index

The message index position.

Integer
返回值
数据类型说明
Integer

The severity of the specific message.

  • 0informational message
  • 1warning message
  • 2error message

代码示例

Result example 1

Use the result object returned from GetCount to determine the count of a table.

import arcpy
inTable = arcpy.GetParameterAsText(0)
result = arcpy.GetCount_management(inTable)
print result.getOutput(0)
Result example 2

Obtain feature set schema from server tool, load data to feature set, pass feature set to server tool, and check for result object. Once completed, save result to local dataset.

import arcpy
import time  

# Add a toolbox from a server 
#
arcpy.ImportToolbox("http://myserver/arcgis/services;GP/BufferByVal", "server") 

# Use GetParameterValue to get a featureset object with the default
#   schema of the first parameter of the tool 'bufferpoints' 
#
inFeatureSet = arcpy.GetParameterValue("bufferpoints", 0) 

# Load a shapefile into the featureset 
#
inFeatureSet.load("C:/Data/roads.shp") 

# Run a server tool named BufferPoints with featureset created above 
# 
result = arcpy.BufferPoints_server(inFeatureSet, "500 feet") 

# Check the status of the result object every 0.2 seconds 
#    until it has a value of 4(succeeded) or greater 
# 
while result.status < 4:
    time.sleep(0.2)
 
# Get the output FeatureSet back from the server and save to a local geodatabase 
# 
outFeatSet = result.getOutput(0)
outFeatSet.save("C:/Temp/Base.gdb/roads_buffer")
Result example 3

Re-create the original geoprocessing service output using the tool name and result id.

import arcpy

# Add the toolbox from the server
#
arcpy.ImportToolbox("http://myserver/arcgis/services;GP/BufferByVal")

# Recreate the original output using the tool name and result id
#
result_id = 'jfea96e13ba7b443cb04ba47c19899a1b'
result = arcpy.Result("BufferPoints", result_id)

相关主题


7/10/2012