Select to view content in your preferred language

Create view layer in arcgis python api and make certain fields visiblity to be off and editable properties should be false

07-21-2023 06:10 AM
Labels (2)
New Contributor

I have created a view_layer using below code but i have not get any reference to update the visibility and editability properties for each feature layers. I have use the below code, please refer any process of how i could be able to update the properties.





import arcgis
from arcgis.features import FeatureLayer
from arcgis.features import FeatureLayerCollection

user_name = "UserName"
pass_word = "PassWord"
gis = arcgis.gis.GIS("", user_name, pass_word)
layer_name = "My_layer"
view_name = "My_view1"
layer_index = 0
view_def = {"viewDefinitionQuery": "Fields in ['ch_name']"}

search_results =, item_type="Feature Layer")
proper_index = [index for index, s in enumerate(search_results)
if '"' + layer_name + '"' in str(s)]
found_item = search_results[proper_index[0]]
flc = FeatureLayerCollection.fromitem(found_item)
new_view = flc.manager.create_view(name=view_name)
view_flc = flc
view_layer = view_flc.layers[layer_index]





The code show error for the following line:
"view_def = {"viewDefinitionQuery": "Fields in ['ch_name']"}"
Please assist me to write the veiw defination correctly to disply only selected fields.


Tags (1)
2 Replies
New Contributor III

By setting the the specific fields visibile and editable properties to be False and then update_defination for the feature collection we can achieve it.

Occasional Contributor III

Did you ever find an answer for this? I was searching for the same thing and came across your just doesn't have much in it. 

0 Kudos