Select to view content in your preferred language

Setting Visibility Scale using the ArcGIS API for Python

1814
6
10-14-2019 08:18 AM
GISUser17
Emerging Contributor

How can the visibility scale be set using the ArcGIS API for Python

When I set the visibility scale for a list of Feature Layers in an AGOL map and update the Feature Layers, the visibility scale settings for each layer goes back to the default.

Is there a way to update the visibility scale settings using the ArcGIS API for Python? I don't want to have to go in and set the visibility scale settings manually after every update.

Thanks.

0 Kudos
6 Replies
RobertBorchert
Honored Contributor

You should switch to use Pro. You manually set your visibilities there once and every time you publish they stay the same.
However, I  never had an issue publishing from and MXD either, they always stayed as they were in the MXD

AGO Online, or other it is all the same. Do you use grouping in your MXD or Project.  That may be doing away with your Visibility settings

0 Kudos
GISUser17
Emerging Contributor

Hi Robert,

Thanks for your reply.

The map is created in AGOL, not published from ArcGIS Pro or an MXD.

The process needs to be automated as the data is updated frequently and needs to be uploaded regularly and frequently. As soon as a change is made to the database a process is started automatically that uploads the new datasets to AGOL.

If there is not a way to set the visibility scale using the API, can a service published from an MXD, as you describe, be automated?

Thanks.

Regards.

GIU.

0 Kudos
RobertBorchert
Honored Contributor

If you can publish a service definition from an mxd or Pro it should set up your features just like they would be have on your desktop version. However, if the name of the data is changing then you may have to look to a scripted fix.

0 Kudos
GISUser17
Emerging Contributor

Hi,

I could do that and the data names and schemas are unchanged between updates. However, my understanding of AGOL is that datasets are not automatically updated from the source, in this case an SDE GeoDatabase.

Once the service definition is published, how are the datasets now on AGOL updated when the database is updated?

Thanks.

0 Kudos
GarasLewis
Emerging Contributor

How do you do this in jupyter (python)?

how do i add a layer and change when it turns on based on zoom? Like if i zoom out I want a layer to deactivate(hide), and when i zoom in i want to be able to see it again. see the given layer below as an example. And how do i get the legend to appear, i found ".legend" but it doesn't work?

from arcgis.features import FeatureLayer
polygon_layer = FeatureLayer(url="https://gisservices.information.qld.gov.au/arcgis/rest/services/Farming/DroughtDeclarations/MapServer")

WebMap = gis.map('Queensland')
WebMap.add_layer(polygon_layer)
WebMap.legend = True
WebMap

0 Kudos
LukasWürsch
Regular Contributor

Hi, not sure if you are still looking for an answer, you can look here for a code example showing how to set the visibility range with the Python API

0 Kudos