Select to view content in your preferred language

Feature layer overwrite not working in notebook

73
0
02-13-2025 09:41 AM
Labels (1)
DrewLaird
New Contributor

I am using a notebook to extract information from hosted feature services and combine it with API calls to yield a new dataset. I'd like this dataset to be published to a feature layer which then gets updated on a daily basis.

This dataset is in the form of a pandas data frame, which then gets converted to a spatial data frame and published as a feature layer using the following block of code:

sdf = pd.DataFrame.spatial.from_xy(incident_predictions, x_column='longitude', y_column='latitude')

# Specify the title and tags for your feature service
title = "Incident Predictions"
tags = "dams, incidents"

# Publish the Spatially Enabled DataFrame
feature_layer = sdf.spatial.to_featurelayer(title=title, 
                                            tags=tags,
                                            gis=gis,
                                            folder='Dam Data + Code',
                                            overwrite=True,
                                            service= {'featureServiceId' : '850e4666b2934cf696f809bf5aeaf2c8', 'layer': 0})

 

I have a task that runs the notebook on a daily basis and gets the expected result, however, the overwrite feature is not working. I have inputted the correct feature service ID, but when I check the next day for the feature layer, I have one with an identical name but a different ID. Additionally, whenever this code is run, it creates a new geodatabase file, and I am unsure what part of my code is creating this geodatabase when I am only trying to publish a feature layer.

 

Any help would be appreciated, I'd just want to have a feature layer updated every day using an automated task with new data from the API calls I make in the notebook.

 

 

0 Kudos
0 Replies