Does anyone know how you would, using the Python API, create a feature layer view in ArcGIS Online (or Portal 10.5 for that matter I guess)?
I'm referring here to the new views capability that arrived in AGOL back in December, that allows you to create a view of an existing hosted feature layer, but with different editing capabilities, field visibility, filtered features etc.
Solved! Go to Solution.
Has this capability been added yet? (create Feature Layer View on AGOL via Python API)
if not can you recommend an alternative approach? Its an important aspect that appears to be overlooked.
I eventually found that also, but since I’m new to this I assumes this only worked with Feature Collections... I’ll give it another go this morning. I don’t see any method for applying the ‘filter’ or ‘query definition’ to the view that’s created, would you have an idea on this also please - apologies for using you as technical help .... thanks again and I appreciate the response to the initial question , it helps as I’m just starting with this api.
You can set the view definition query by updating the layer definition (not sure if you can directly set it when adding layers to the definition, haven't tried).
Has anyone figured out how to specify the view_layers?? Below are two samples. The first successfully creates a view. The second attempts to create a view but specifying only a single layer from the feature layer collection using view_layers. It doesn't work, returns an error "'FeatureLayerManager' object has no attribute 'manager'".
from arcgis import GIS, features
mygis = GIS("https://www.arcgis.com", username, password)
###create variable for feature layer collection where feature service has 20 layers
flc = features.managers.FeatureLayerCollectionManager('https://services6.arcgis.com/<organizaionid>/ArcGIS/rest/admin/services/<featureservicename>/FeatureServer',mygis)
Working Sample - creates view with all 20 layers
view = flc.create_view(name="GM_copy_burnview", capabilities = 'Create,Editing,Query,Sync,Update')
Failing Sample - attempts to create view with layer 14 only
view = flc.create_view(name="GM_copy_burnview", capabilities = 'Create,Editing,Query,Sync,Update', view_layers = [flc.layers])