Can't overwrite a join_features output layer using ArcGIS Online Notebook Tasks

09-21-2022 06:02 AM
New Contributor III

Hi all, 

I have the below code written in AGOL notebook and its purpose is to join features of two feature layers. The output layer will need to be overwritten regularly through running the code every day and the layer also needs to be maintained because it will be used to build a dashboard. I used the Tasks functionality to run the code everyday, but I always get the below error, despite having the Overwrite parameter in my join_features function. Any idea how I can achieve that? 


The error: 

"The provided output name is already in use or contains invalid characters."



The code:


from arcgis.gis import GIS
gis = GIS("home")

itemDis = gis.content.get("8119.............14")

itemSrv = gis.content.get("2056ad................fa73")

from arcgis import features

intersectionLayer= features.summarize_data.join_features(target_layer=itemDis,
                                                                                                        output_name='intersection features',
                                                                                                        context = {"overwrite": True})

5 Replies
New Contributor III

Hi @SeanKMcGinnis, I've seen your contributions to relevant questions and wondered if you could help me with that please? Or could you guide me to the right direction/person?   

0 Kudos
New Contributor III

hello, i have the same problem. did you find a solution?

0 Kudos
New Contributor III

Hi, unfortunately not. I believe the overwrite parameter has been deprecated in the new API version. That's why it's not functioning as expected. Any luck with you?

0 Kudos
New Contributor

I'm having the same issue, did you ever find a workaround?

0 Kudos
Esri Contributor

Hi @AhmedShehata3 @EmilyMills11 @JiříKomínek,

In order to use "overwrite": True in the context parameter, the output_name must be a feature layer, not a text string. 

Here's a sample code:

from arcgis.gis import GIS
gis = GIS("home")
from arcgis import features
polygon_target = gis.content.get('<ITEM_ID_1>')
polygon_join = gis.content.get('<ITEM_ID_2>'')
new_feature = gis.content.get('<ITEM_ID_3>'')
new_feature_lyr = new_feature.layers[0]
from arcgis.features.summarize_data import join_features
join_features(target_layer = polygon,
                                  join_layer = point,
                                  spatial_relationship = 'intersects'
                                  output_name = new_feature_lyr,
                                  context = {"overwrite": True})
There is a known bug with this, as it creates duplicate layers in the feature layer. There is a documented workaround:

Use ArcGIS Online Assistant to remove sublayers from feature layer. NOTE: ArcGIS Online Assistant is not supported by Esri Technical Support.

1. Navigate to and Log In.

2. Under "My Content", find the target feature layer and click it. Click "View Item JSON".

3. Click on the "Data Tab". Click "Edit JSON".

4. Delete the duplicate json data. Be sure to keep the original ("id": 0). Deleting it all will break the layer and any dependent apps.

Ryan Grammer | ArcGIS Support Analyst
Esri | 380 New York St | Redlands, CA 92373 | USA

0 Kudos