Result
Zusammenfassung
A Result object is returned by geoprocessing tools.
Beschreibung
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.
Syntax
Parameter | Erläuterung | Datentyp |
toolname |
The name of the executed tool. | String |
resultID |
The job ID. | Integer |
Eigenschaften
Eigenschaft | Erläuterung | Datentyp |
inputCount (Nur lesen) |
Gibt die Anzahl der Eingaben zurück. | Integer |
maxSeverity (Nur lesen) |
Gibt die höchste Gewichtung der Meldung zurück. | Integer |
messageCount (Nur lesen) |
Gibt die Anzahl der Meldungen zurück. | Integer |
outputCount (Nur lesen) |
Gibt die Anzahl der Ausgaben zurück. | Integer |
resultID (Nur lesen) |
Ruft die Auftrags-ID ab. Wenn es sich bei dem Werkzeug nicht um einen Geoverarbeitungs-Service handelt, ist resultID gleich "". | String |
Status (Nur lesen) |
Ruft den Auftragsstatus ab.
| Integer |
Methodenübersicht
Methode | Erläuterung |
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. |
Methoden
Parameter | Erläuterung | Datentyp |
index |
The index position of the input. | Integer |
Datentyp | Erläuterung |
Object |
The input, either as a recordset or string. |
Parameter | Erläuterung | Datentyp |
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 |
Datentyp | Erläuterung |
String |
The URL of the map image. |
Parameter | Erläuterung | Datentyp |
index |
The index position of the message. | Integer |
Datentyp | Erläuterung |
String |
The geoprocessing message. |
Parameter | Erläuterung | Datentyp |
severity |
The type of messages to be returned: 0=message, 1=warning, 2=error. Not specifying a value returns all message types.
(Der Standardwert ist 0) | Integer |
Datentyp | Erläuterung |
String |
The geoprocessing messages. |
Parameter | Erläuterung | Datentyp |
index |
The index position of the outputs. | Integer |
Datentyp | Erläuterung |
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. |
Parameter | Erläuterung | Datentyp |
index |
The message index position. | Integer |
Datentyp | Erläuterung |
Integer |
The severity of the specific message.
|
Codebeispiel
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)
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")
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)