Select to view content in your preferred language

How to copy a "list feature" to a feature class ?

364
1
04-11-2022 07:19 AM
NicolasDELAVAL
Emerging Contributor

Hi,

I have constructed a list ("feat_to_add") that describes a feature that I want to add to a hosted feature layer in my Portal.

[{"geometry": {"paths": [[[2.9244314, 42.7770192], [2.9519563, 42.7748966], [2.951957, 42.7748306], [2.9518368, 42.7748318]]], "spatialReference": {"wkid": 4326, "latestWkid": 4326}}, "attributes": {"username": "DH283LK", "start_time": 1649155161000, "end_time": 1649155732000, "numimmat": "DH-283-LK", "activite": "Collecte", "commune": "Test", "duree": 9.650000000000192, "commentair": "Test"}}]

No problem using the function : layer.edit_features(adds=feat_to_add)

My feature was correctly added to my hosted feature layer.

But in addition to updating my Portal, I would also like to copy this feature to a feature class of a local FGDB.

I tried :

arcpy.CopyFeatures_management(feat_to_add, "c:/Temp/temp.gdb/test")

but return (in french) : "RuntimeError: Objet : erreur lors de l’exécution de l’outil"

So I tried :

featset = arcgis.features.FeatureSet(feat_to_add)
featset.save(save_location = "c:/Temp/temp.gdb", out_name = "test")

but return : "ExecuteError: ERROR 001558: Error parsing json file 'C:\Users\c3sm1\AppData\Local\Temp\ArcGISProTemp24060\41e954ab3c0b459c94922d89c5763fd2.json'. Ce type de valeur est incompatible avec ce type de champ. [start_time]
Échec de l’exécution de (JSONToFeatures)."

Can you please help me find the solution to copy my feature to a local feature class.

Thank you.

Tags (1)
0 Kudos
1 Reply
NicolasDELAVAL
Emerging Contributor

CopyFeatures_management.pngsave.png

0 Kudos