Result

Résumé

A Result object is returned by geoprocessing tools.

Discussion

The advantage of a Result object is that you can maintain information about the execution of tools, including messages, parameters, and output. These results can be maintained even after several other tools have been run.

Syntaxe

 Result  (toolname, resultID)
ParamètreExplicationType de données
toolname

The name of the executed tool.

String
resultID

The job ID.

Integer

Propriétés

PropriétéExplicationType de données
inputCount
(Lecture seule)

Returns the number of inputs.

Integer
maxSeverity
(Lecture seule)

Returns the maximum severity of the messages.

  • 0If the tool produced only informative messages.
  • 1 If the tool produced a warning message, but no error messages.
  • 2 If the tool produced an error message.
Integer
messageCount
(Lecture seule)

Returns the number of messages.

Integer
outputCount
(Lecture seule)

Returns the number of outputs.

Integer
resultID
(Lecture seule)

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

String
status
(Lecture seule)

Gets the job status.

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

Vue d’ensemble des méthodes

MéthodeExplication
cancel ()

Cancels an associated job

getInput (index)

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

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

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

getMessage (index)

Returns a specific message by index position.

getMessages ({severity})

Returns the geoprocessing tool messages.

getOutput (index)

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

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

getSeverity (index)

Returns the severity of a specific message.

saveToFile (rlt_file)

Saves the result to a result file.

Remarque :

saveToFile is not supported in ArcGIS Pro; use the Package Result tool instead.

Méthodes

cancel ()
getInput (index)
ParamètreExplicationType de données
index

The index position of the input.

Integer
Valeur renvoyée
Type de donnéesExplication
Object

The input, either as a recordset or string.

getMapImageURL ({parameter_list}, {height}, {width}, {resolution})
ParamètreExplicationType de données
parameter_list

The parameters 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
Valeur renvoyée
Type de donnéesExplication
String

The URL of the map image.

getMessage (index)
ParamètreExplicationType de données
index

The index position of the message.

Integer
Valeur renvoyée
Type de donnéesExplication
String

The geoprocessing message.

getMessages ({severity})
ParamètreExplicationType de données
severity

The type of messages to be returned.

  • 0Informative, warning, and error messages are returned.
  • 1Only warning messages are returned.
  • 2Only error messages are returned.

Not specifying a severity level will return all types of messages.

(La valeur par défaut est 0)

Integer
Valeur renvoyée
Type de donnéesExplication
String

The geoprocessing tool messages.

getOutput (index)
ParamètreExplicationType de données
index

The index position of the outputs.

Integer
Valeur renvoyée
Type de donnéesExplication
Object

The output, either as a recordset or a string.

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

Result outputs can also be accessed by index, so result.getOutput(0) and result[0] are equivalent.

getSeverity (index)
ParamètreExplicationType de données
index

The message index position.

Integer
Valeur renvoyée
Type de donnéesExplication
Integer

The severity of the specific message.

  • 0Informative, warning, and error messages are returned.
  • 1Only warning messages are returned.
  • 2Only error messages are returned.
saveToFile (rlt_file)
ParamètreExplicationType de données
rlt_file

Full path to the output result file (.rlt).

String

Exemple de code

Result example 1

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

import arcpy

in_table = arcpy.GetParameterAsText(0)
result = arcpy.GetCount_management(in_table)
print(result[0])
Result example 2

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

import time
import arcpy

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

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

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

# Run a server tool named BufferPoints with featureset created above
result = arcpy.BufferPoints_server(in_featureset, "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
out_featureset = result.getOutput(0)
out_featureset.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)

Rubriques connexes