copy_feature_layer_collection : layers=???

260
2
11-25-2019 08:18 AM
JUBJUB
by
New Contributor II

Hi,

I try to use copy_feature_layer_collection from Arcgis API Python : https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html?highlight=clone#arcgis.gis.... 

I am wondering how to pass the parameter layers that I want to copy ?

I tried with :

layers=[0,1,2,3]

layers=[0 1 2 3]

layers=["0,1,2,3"]

layers=["0","1","2","3"]

But no success... If you have an idea !!

Many thanks

JUB

2 Replies
AshtonWoodrow1
New Contributor III

I wish you could upvote this stuff for relevance. I have a case open with support right now on the same issue. I will let you know what I find.

The weird thing is if you use the copy() call it works just fine:

argis.gis.Item(GIS, 'some_item_id').copy('new_layer_name', layers = [0,1,2,3])

copy_feature_layer_collection also works but only if you pass 1 value in the list.

arcgis.gis.Item(gis, 'some_item_id').copy_feature_layer_collection('new_layer_name', layers = [0])

Not that it should matter, but I even tried creating the list as a separate variable and passing that variable as a parameter to the argument. Still no luck. Everything seemingly valid produces Error 500: JSON does not allow non-finite numbers.

I have looked at arcgis.gis.Item.publish() but the amount of hoops you would haver to jump through to query the original layer for it's properties and create dictionary for the publish call's parameters makes it too much of  headache.

I am going to rebuild the code in Pycharm and step through it while I wait for support to get back to me.

If anyone stumbles across this thread and has used it successfully in copying multiple layers in a feature layer collections, please let us know how you did it!!! It would be greatly appreciated.

0 Kudos
spatialcase
New Contributor II

try layers={0,1,2,3}

Good Luck, Graham

0 Kudos