ArcGIS for Desktop

  • 文档
  • 合约
  • 支持

  • My Profile
  • 帮助
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

专为贵组织打造的制图平台

ArcGIS for Desktop

全面的专业性 GIS

ArcGIS for Server

面向企业的 GIS

ArcGIS for Developers

用于构建位置感知应用程序的工具

ArcGIS Solutions

适用于行业的免费模板地图和应用程序

ArcGIS Marketplace

获取适用于组织的应用程序和数据

  • 文档
  • 合约
  • 支持
Esri
  • 登录
user
  • 我的个人资料
  • 登出

帮助

  • 主页
  • 入门
  • 制图
  • 分析
  • 管理数据
  • 工具
  • 更多...

Result

  • 摘要
  • 讨论
  • 语法
  • 属性
  • 方法概述
  • 方法
  • 代码实例

摘要

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

讨论

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

语法

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

已执行工具的名称。

String
resultID

作业 ID。

Integer

属性

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

Returns the number of inputs.

Integer
maxSeverity
(只读)

Returns the maximum severity of the messages.

  • 0 —If 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
(只读)

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.

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

方法概述

方法说明
cancel ()

取消关联的作业

getInput (index)

以记录集或字符串的形式返回给定的输入。

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

获取给定输出的地图服务影像(如果存在)。

getMessage (index)

返回特定消息。

getMessages ({severity})

返回消息。

getOutput (index)

以记录集或者字符串形式返回给定的输出。

如果工具(如 MakeFeatureLayer)的输出是一个图层,则 getOutput 将返回 Layer 对象。

getSeverity (index)

返回特定消息的严重性。

saveToFile (rlt_file)

将结果保存至结果文件 (.rlt)。

方法

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

输入的索引位置。

Integer

返回值

数据类型说明
Object

记录集或者字符串形式的输入。

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

地图服务影像所基于的参数。

Integer
height

影像的高度。

Double
width

影像的宽度。

Double
resolution

影像的分辨率。

Double

返回值

数据类型说明
String

地图影像的 URL。

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

消息的索引位置。

Integer

返回值

数据类型说明
String

地理处理消息。

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

要返回的消息类型:0 = 消息,1 = 警告,2 = 错误。如果未指定值,则返回所有消息类型。

  • 0 —信息性消息
  • 1 —警告消息
  • 2 —错误消息

(默认值为 0)

Integer

返回值

数据类型说明
String

地理处理消息。

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

The index position of the outputs.

Integer

返回值

数据类型说明
Object

输出为记录集或者字符串形式。

如果工具(如 MakeFeatureLayer)的输出是一个图层,则 getOutput 将返回 Layer 对象。

还可按索引访问结果输出,因此 result.getOutput(0) 和 result[0] 是等效的。

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

消息索引位置。

Integer

返回值

数据类型说明
Integer

特定消息的严重性。

  • 0 —信息性消息
  • 1 —警告消息
  • 2 —错误消息
saveToFile (rlt_file)
参数说明数据类型
rlt_file

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

String

代码实例

Result 示例 1

使用从 GetCount 返回的结果对象来确定表计数。

import arcpy

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

从服务器工具获取要素集方案、将数据加载至要素集,将要素集传递到服务器工具并检查结果对象。完成后,将结果保存到本地数据集。

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 示例 3

使用工具名称和结果 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)

相关主题

  • 通过 Python 使用工具
有关此主题的反馈?

ArcGIS for Desktop

  • 主页
  • 文档
  • 合约
  • 支持

ArcGIS 平台

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • 内部人员博客
  • 用户大会
  • 开发者峰会
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | 隐私政策 | 法律声明