Create Feature Layer using ArcGIS API for Python

2924
3
Jump to solution
03-03-2017 02:28 PM
ZacharyNeumann1
New Contributor III

I have a feature layer hosted in my organization that I want to turn into a new feature layer in my content, similar to this functionality:

I was messing around with some code:

base_comment_layer = gis.content.get('# acutal item ID goes here')

layer_properties={
'title':'Test_Comment_Layer',
'description':'This is a comment layer that is being used for testing purposes only',
'tags':'TPCM, Test, Python, Comment Layer'
}

gis.content.add(item_properties=layer_properties, data=base_comment_layer, folder='test_NF')

but that didn't seem to work, I was getting an error:

AttributeError: 'Item' object has no attribute 'replace'

This is obviously after longing on using the GIS() method.

Any adivice?

Thanks.

1 Solution

Accepted Solutions
ZacharyNeumann1
New Contributor III

I solved my issue. For those interested:

layer_properties={
'title':'Test_Comment_Layer',
'description':'This is a comment layer that is being used for testing purposes only',
'tags':'TPCM, Test, Python, Comment Layer',
'type':'Feature Service',
'url':'URL to Feature Service'
}

gis.content.add(item_properties=layer_properties, data="URL to Feature Service", folder='test_NF')

View solution in original post

3 Replies
ZacharyNeumann1
New Contributor III

I solved my issue. For those interested:

layer_properties={
'title':'Test_Comment_Layer',
'description':'This is a comment layer that is being used for testing purposes only',
'tags':'TPCM, Test, Python, Comment Layer',
'type':'Feature Service',
'url':'URL to Feature Service'
}

gis.content.add(item_properties=layer_properties, data="URL to Feature Service", folder='test_NF')

View solution in original post

PhilippNagel1
New Contributor II

Thank you Zachary! Very helpful. This is not the most intuitive, and not covered very well in the docs.

0 Kudos
MaximeCampeau
New Contributor II

can you define more on how you get the item's ID ? Especially if you generate the results automatically from a script and you simply want to move that feature layer into another folder on your arcgis online profile?