Select to view content in your preferred language

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

1135
5
09-21-2022 06:02 AM
AhmedShehata3
Occasional Contributor

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")
itemDis

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

from arcgis import features

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

5 Replies
AhmedShehata3
Occasional Contributor

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
JiříKomínek
Occasional Contributor

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

0 Kudos
AhmedShehata3
Occasional Contributor

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
EmilyMills11
New Contributor

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

0 Kudos
RyanGrammer21
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 assistant.esri-ps.com 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
rgrammer@esri.com

THE SCIENCE OF WHERE ®
0 Kudos