In the official documentation, detect_object
said to be able to use existing Feature Service for the output_name
variable.
output_name
Optional. If not provided, a FeatureLayer is created by the method and used as the output . You can pass in an existing Feature Service Item from your GIS to use that instead. Alternatively, you can pass in the name of the output Feature Service that should be created by this method to be used as the output for the tool. A RuntimeError is raised if a service by that name already exists
However, I got this error
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
In [30]:
Line 1: out_objects = detect_objects(
File D:\Program Files\ArcGIS\Pro\bin\Python\envs\arc-big\Lib\site-packages\arcgis\learn\__init__.py, in detect_objects:
Line 347: return gis._tools.rasteranalysis.detect_objects_using_deep_learning(
File D:\Program Files\ArcGIS\Pro\bin\Python\envs\arc-big\Lib\site-packages\arcgis\_impl\tools.py, in detect_objects_using_deep_learning:
Line 11600: output_service_name = output_objects.replace(" ", "_")
File D:\Program Files\ArcGIS\Pro\bin\Python\envs\arc-big\Lib\site-packages\arcgis\gis\__init__.py, in __getattr__:
Line 13557: raise AttributeError(
AttributeError: 'Item' object has no attribute 'replace'
---------------------------------------------------------------------------
MRE
from arcgis import GIS
from arcgis.learn import Model, detect_objects
gis = GIS(
url='url', # fill with correct credentials
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') # this is the target feature service
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
)
Questions
My goal is to append the inferencing result to an existing feature service
- Given the error, is it correct for me to assume that currently the variable only accepts string as input?
- If it is, is it possible to append the inferencing result (assume that I have the item id for the existing feature service I want to append) to the existing feature service using
detect_objects
only? (I have the work around with.edit_features()
, but to me the documentation implies it can use an existing feature service as the output, so I'm curious) - If it is not (i.e. it can actually use another kind of input), what kind of input do I need to put to make it append the result to an existing feature service
- If it is, is it possible to append the inferencing result (assume that I have the item id for the existing feature service I want to append) to the existing feature service using
Thanks!