How to create a feature layer view in AGOL

2407
20
Jump to solution
04-12-2017 11:14 PM
PaulHaakma
Regular Contributor

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

1 Solution

Accepted Solutions
AtmaMani
Esri Contributor

Paul, we don't support this yet. However we have reviewed this request and will consider for the subsequent versions.

View solution in original post

0 Kudos
20 Replies
AtmaMani
Esri Contributor

Paul, we don't support this yet. However we have reviewed this request and will consider for the subsequent versions.

View solution in original post

0 Kudos
jonathanharte
New Contributor III

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

0 Kudos
GregStevenson
New Contributor III

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

jonathanharte
New Contributor III

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

0 Kudos
AaronPulver
Esri Regular Contributor

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'
})
jonathanharte
New Contributor III

Thanks Aaron,

an example of this process would be good in the samples section

thanks for the response, appreciated

paulg

0 Kudos
ThomasPaschke1
Esri Contributor

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 StevensonAaron Pulver jonathan harte

Thanks!

Best,

Thomas

0 Kudos
ThomasPaschke1
Esri Contributor

Nevermind I found the mistake. Need to update the definition of the FeatureLayer not the FeatureLayerCollection

0 Kudos
MitchEast
New Contributor III

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]])

0 Kudos