Hello - I am trying to append one feature layer to another in ArcGIS Online using the ArcGIS API for Python. Code below. I am receiving the error: RuntimeError: Object reference not set to an instance of an object.(Error Code: 400)
@GeofyAdmin -- if you still have the sample code for this, that would be much appreciated!
Got it, thank you. A working code showing how to get a featurecollection out of the one layer within the hosted feature layer would be much appreciated. Thank you for the assistance.
a featurecollection would be the closest to your case.
look at the upload_format of the append method.
You would need to get a featurecollection out of one of the layers of your hosted feature service
If you run into any issues let me know and I’ll write a working code for you but tomorrow because it’s a bit late where I am
Is a hosted feature layer an acceptable item? The source dataset is a hosted feature layer that can be seen below.
Sure but also pay attention to the item_id parameter to the append method.
It’s expecting a certain type of portal item, I.e. an uploaded file: shapefile, geojson etc.
My apologies, the flayer is declared above the screenshot I sent. I will try the field mappings. Thank you for the quick response.
well, your flayer is undeclared!
To clarify the proper workflow of what you are trying to do:
1. First get the hosted feature service containing the layer you want to update/append, like this FS=gis.content.get('itemID here')
2. Get the layer like this FL=FS[0] or whatever index/name you have
3. Get the item id of the AGOL item containing source data (could be a shapefile or whatever you have previously uploaded. I am assuming a geojson file) agolId=gis.content.get('itemID here')
4. Now attempt to append like this: ret=FL.append(item_id=agolId, upsert=false, update_geometry=true, upload_format='geojson')
5. Optionally you should check the ret variable to see if success or failire
Finally, fields should match between source and dest. If not, you can make use of the field_mappings prop of the append method
Good luck and check append doc below
arcgis.features module — arcgis 1.8.0 documentation
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.