What is the maximum number of views on a Hosted Feature Layer?

2418
4
03-14-2019 02:36 PM
Egge-Jan_Pollé
MVP Regular Contributor

Hi,

I just wondered: is there a limitation on the number of views you can create on a Hosted Feature Layer? In ArcGIS Online and/or in Portal for ArcGIS?

On this page (Create hosted feature layer views—Portal for ArcGIS | ArcGIS Enterprise) it is stated that

You can create a maximum of 20 views from the same hosted feature layer.

whereas on this page (Create hosted feature layer views—ArcGIS Online Help | ArcGIS) this limitation seems absent (although there is a limit of 20 to the number of categories you can assign to the item....)

And this limitation of 20 views on a Hosted Feature Layer in Portal for ArcGIS Enterprise, is that just a limitation of the UI which can be circumvented using a Python script, as kimberly peter states on GitHub (Add information and a sample for creating hosted feature layer views using Python · Issue #340 · Esr... )?

With the Python script below I can create 25 views on a Hosted Feature Layer in ArcGIS Online. Would a similar approach be possible in Portal for ArcGIS Enterprise?

TIA,

Egge-Jan

from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection
from provide_credentials import provide_credentials

username, password = provide_credentials()
my_agol = GIS("https://www.arcgis.com", username, password)

service = my_agol.content.get("<serviceItemId_of_your_Hosted_Feature_Layer>")

flc = FeatureLayerCollection.fromitem(service)

clients = ['ONE','TWO','THREE','FOUR','FIVE','SIX',
'SEVEN','EIGHT','NINE','TEN','ELEVEN','TWELVE',
'THIRTEEN','FOURTEEN','FIFTEEN','SIXTEEN','SEVENTEEN','EIGHTEEN',
'NINETEEN','TWENTY','TWENTY-ONE','TWENTY-TWO','TWENTY-THREE','TWENTY-FOUR',
'TWENTY-FIVE']

for client in clients:
    view_name = service.name + "_View_" + client
    print(view_name)
    view = flc.manager.create_view(name=view_name, spatial_reference=None, extent=None, allow_schema_changes=True, updateable=True, capabilities='Query, Update', view_layers=None)
    for lyr in view.layers:
        query = "Description = '%s'"%(client)
        print(query)
        lyr.manager.update_definition({'viewDefinitionQuery': query})
4 Replies
by Anonymous User
Not applicable

There is a property in the service json definition (of the source feature service) called "maxViewsCount". By default this is set to 20 for performance reasons especially when fields on the source feature service are modified and the changes need to be propagated to the views. However, you can call updateDefinition on the feature service (not the layer) to modify this value. I believe this is only a limitation for ArcGIS Enterprise but don't quote me on that.

If you try to create more views than the maxViewsCount, you will get an error returned from the server. 

Egge-Jan_Pollé
MVP Regular Contributor

OK - Tnx. Will investigate and get back to you to mark this as the right answer as soon as I have confirmed this for myself 🙂

0 Kudos
JanBurdziej
New Contributor III

Hi,

we have one master feature layer with admin boundaries for all countries and territories in the world, including subnational boundaries. We needed separate views with a subset of boundaries for each country, which makes it ~260 views created based on the same source feature layer. I was able to create all views using ArcGIS Python API, though had to run the script a few times due to timeouts etc.

PS. I can't find 'maxViewsCount' property in JSON definition of the source feature service. Has this been removed..?

The question to others: what was the max number of Views that you've created on AGOL? Any performance issues or other implications?

Best,

Jan

0 Kudos
DarraghOSullivan
Occasional Contributor

Hi Jan,

Can I ask if you ever came across performance issues with this many views? A project I'm working on needs up to about 150 views for a large feature service and I'm trying to find out as muh as possible before we go down that route...

Thanks,

Darragh

0 Kudos