You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用ArcGIS Python API的detect_objects追加要素服务遇错咨询

ArcGIS Python API detect_objects 参数报错与追加要素服务问题

问题场景

官方文档显示ArcGIS Python API的detect_objects工具的output_name参数可传入现有Feature Service Item作为输出,但实际传入Item对象时触发以下错误:

AttributeError: 'Item' object has no attribute 'replace'

最小复现代码

from arcgis import GIS
from arcgis.learn import Model, detect_objects

gis = GIS(
    url='url', 
    username='username',
    password='username',
)

detect_objects_model_package = gis.content.get('some_id')
raster = gis.content.get('some_other_id')

detect_objects_model = Model(detect_objects_model_package)
detect_objects_model.install(gis=gis)

test_notebook = gis.content.get('another_id') # 目标要素服务

context = {
    'cellSize': 0.1,
    'processorType':'GPU'
}

out_objects = detect_objects(
    input_raster=raster,
    model=detect_objects_model,
    output_name=test_notebook,
    context=context,
    gis=gis
)

用户问题

  1. 根据错误信息,是否可认为output_name仅接受字符串输入?
    1.1 若是,能否仅通过detect_objects工具将结果追加到指定现有要素服务?(已掌握.edit_features()的替代方案,但文档暗示支持该场景)
    1.2 若否,需传入何种类型的输入才能实现追加到现有要素服务?

回答

  1. 从报错信息判断,output_name确实仅接受字符串类型输入。报错中的replace是字符串专属方法,说明工具内部对该参数执行了字符串操作,传入Item对象必然触发属性不存在的错误。

1.1 仅靠detect_objects工具本身无法实现追加到现有要素服务的需求。即便传入现有要素服务的名称或ID字符串,工具默认行为是覆盖原有服务数据而非追加,且工具没有内置参数支持追加逻辑。文档描述存在歧义,实际工具逻辑并不支持直接追加,还是需要依赖.edit_features()的方案完成结果追加。

1.2 不存在其他类型输入能让detect_objects直接追加到现有要素服务。如果用该工具输出到现有服务,只能传入目标要素服务的名称字符串或Item ID字符串,但会直接覆盖原有数据,无法达成追加目的。


内容的提问来源于stack exchange,提问作者Amri Rasyidi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 12:50:01