ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

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

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS for Developers

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

ArcGIS Solutions

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

ArcGIS Marketplace

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

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

ArcMap

  • 主页
  • 入门
  • 地图
  • 分析
  • 管理数据
  • 工具
  • 扩展模块

Result

  • 描述
  • 说明
  • 语法
  • 属性
  • 方法概述
  • 方法
  • 代码示例

描述

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

说明

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

语法

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

已执行工具的名称。

String
resultID

作业 ID。

Integer

属性

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

返回输入数目。

Integer
maxSeverity
(只读)

返回消息的最大严重性。

  • 0 —如果工具仅产生了信息性消息。
  • 1 — 如果工具产生了警告消息,但未出现错误消息。
  • 2 — 如果工具产生了错误消息。
Integer
messageCount
(只读)

返回消息数目。

Integer
outputCount
(只读)

返回输出数目。

Integer
resultID
(只读)

获得作业 ID。如果工具不是地理处理服务,resultID 将为 ""。

String
status
(只读)

获得作业状态。

  • 0 —新建
  • 1 —已提交
  • 2 —正在等待
  • 3 —执行中
  • 4 —成功
  • 5 —失败
  • 6 —超时
  • 7 —正在取消
  • 8 —已取消
  • 9 —删除中
  • 10 —已删除
Integer

方法概述

方法说明
cancel ()

取消关联的作业

getInput (index)

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

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

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

getMessage (index)

返回特定消息。

getMessages ({severity})

返回消息。

getOutput (index)

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

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

getSeverity (index)

返回特定消息的严重性。

saveToFile (rlt_file)

将结果保存至结果文件。

方法

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

输出的索引位置。

Integer

返回值

数据类型说明
Object

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

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

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

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

消息索引位置。

Integer

返回值

数据类型说明
Integer

特定消息的严重性。

  • 0 —信息性消息
  • 1 —警告消息
  • 2 —错误消息
saveToFile (rlt_file)
参数说明数据类型
rlt_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 Desktop

  • 主页
  • 文档
  • 支持

ArcGIS 平台

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

关于 Esri

  • 关于我们
  • 招贤纳士
  • Esri 博客
  • 用户大会
  • 开发者峰会
Esri
分享您的想法。
Copyright © 2019 Esri. | 隐私政策 | 法律声明