错误

错误:无法为 Load 打开表

Last Published: April 25, 2020

错误消息

在 ArcMap 中,运行 Python 脚本以从 ArcGIS Server 添加的地图服务访问属性表会返回以下错误:

错误:
无法为 Load 打开表
User-added image

原因

发生此错误的原因是地图服务用于访问属性表。 地图服务不允许访问数据,并用于显示地图的表示。

解决方案或解决方法

要解决此问题,请使用以下选项之一:
  • 根据在地图服务的 REST 端点查询的要素创建 Python 脚本。 将响应另存为 JSON 文件,并使用 ArcPy 将 JSON 文件转换为保存在本地地理数据库中的要素图层。 Python 脚本用于访问地图服务。
    :
    只有在要素服务具有查询支持的操作时,才能运行查询。 有关详细信息,请参阅 ArcGIS REST API:查询(地图服务/图层)。
    1. 使用 JSON 格式的地图服务的 REST 端点处的属性表数据查询所需的要素。
      1. 指定具有所需要素的 Where 子句。
      2. 或者,指定 Out Fields 参数以限制生成的 JSON 文件中的字段。
    2. 创建 Python 脚本,以插入查询中属性表数据的所有要素,以便以 JSON 格式返回。
#import the required modules
import requests
import urllib
import arcpy
import os
url = "[query URL]"

#specify the Where clause and output fields
where ="[Field Name IN ('Field Value')]"
fields = "[Out Fields returned from the query]"

#Declare the request part of the web URL into a parameter
params = urllib.parse.urlencode({'where' : where, 'outFields' : fields, 'f' : 'json' })

#Declare the response from the web page
response = requests.get(url+params)

#Retrieve the JSON as a text
jsn = response.text

#Set the environment workspace
arcpy.env.workspace = "C:\\temp

#Save the JSON to a file
file = open("C:\\temp\\myFeatures.json", "a")
file.write(jsn)
file.close()

#Convert the JSON file named myFeatures" and join the storage folder of the current database with the desired database
arcpy.JSONToFeatures_conversion("C:\\temp\\myFeatures.json", os.path.join("C:\\temp\\Data.gdb", "myfeatures"))

文章 ID:000018476

从 ArcGIS 专家处获得帮助

联系技术支持部门

下载 Esri 支持应用程序

转至下载选项

相关信息

发现关于本主题的更多内容