Select to view content in your preferred language

Unable to Update/Overwrite Feature Layer using ArcGIS Python API

684
2
12-01-2023 12:35 PM
Labels (1)
Josh-R
by
Regular Contributor

I have a hosted feature layer that I am trying to update/overwrite with new data in the same format with the python API. It is uploaded to AGOL as a geodatabase then published to a feature layer.

I've adapted @JakeSkinner's   method using update and publish and I have tried the overwrite method described in this link. Both methods return {success= true}, however the data remains the same. The Data Updated indicator in the Data tab updates, but no changes. It also appears that no matter what string (even a nonsense string like "adafcfa") I input for the data argument in the overwrite function, it returns {success= true}. Feeling like I've tried just about everything, I could find, please help!

Here are the functions I've tried:

 

 

from arcgis import GIS
from arcgis.features import FeatureLayerCollection
from arcgis.features import GeoAccessor, GeoSeriesAccessor
gis = GIS(username=un, password=pw)

# Method 1
county_item_id = 'b6e449d2fde842ec8e38bb764f95cc2e' # the geodatabase
county_zip = r".\Outputs\map\COUNTY.gdb.zip"
item = gis.content.get(county_item_id)
item.update(data=new_zip)
item.publish(overwrite=True, file_type='fileGeodatabase')

# Method 2
county_item_id = '076737c0837a4673840303deda826119' # the feature layer
county_zip = r".\Outputs\map\COUNTY.gdb.zip"
item = gis.content.get(county_item_id)
flayer_collection = featureLayerCollection.fromitem(item)
flayer_collection.manager.overwrite(county_zip)

 

 

0 Kudos
2 Replies
Josh-R
by
Regular Contributor

I would add that method #1 works when there is only one feature layer in a geodatabase. There are multiple features in this geodatabase; could this be the reason?

0 Kudos
JakeSkinner
Esri Esteemed Contributor
0 Kudos