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.
Cheers,
-Paul
Solved! Go to Solution.
Paul, we don't support this yet. However we have reviewed this request and will consider for the subsequent versions.
Paul, we don't support this yet. However we have reviewed this request and will consider for the subsequent versions.
Hi Guys,
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.
Regards
paulg
Hi, the functionality is documented here:
arcgis.features.managers module — arcgis 1.4.1 documentation
Took us a while to find it too.
Thanks,
Greg
Thanks Greg,
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.
Paulg
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).
view_layer.manager.update_definition({ 'viewDefinitionQuery': '1=1' })
Thanks Aaron,
an example of this process would be good in the samples section
thanks for the response, appreciated
paulg
Hey guys,
Thanks for the solution! However, I only get a 500 error back when trying to set the 'viewDefinitionQuery' on a created view. Any idea what is wrong? Greg Stevenson Aaron Pulver jonathan harte
Thanks!
Best,
Thomas
Nevermind I found the mistake. Need to update the definition of the FeatureLayer not the FeatureLayerCollection
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[14]])