Select to view content in your preferred language

Python (jupyter) hide layer based on zoom + aggregate points

565
0
10-17-2019 05:37 PM
GarasLewis
Emerging Contributor

Going through the arcgis documentation page.

arcgis.features module — arcgis 1.6.2 documentation 

(1)

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. I dont want the map to be cluttered. And how do i get the legend to appear, i found ".legend" but it doesn't work?

point_layer = FeatureLayer(url="https://services1.arcgis.com/okWBWNlpfMx5q1bT/arcgis/rest/services/QFESFireStations/FeatureServer/0")

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

(2)

Is there a way to aggregate points? for example if i have a point layer with lots of points can i merge those points together based on some distance? for that layer?

EDIT:

I found clustering (into groups of colour) based on distance, but cant aggregate to size...

arcgis.features.analysis module — arcgis 1.6.2 documentation 

For some reason when i do it im getting the error:

WARNING 001605: Distances for Geographic Coordinates (degrees, minutes, seconds) are analyzed using Chordal Distances in meters.

from arcgis.features.analysis import find_point_clusters
analysis_layer = "https://services1.arcgis.com/okWBWNlpfMx5q1bT/arcgis/rest/services/QFESFireStations/FeatureServer/0"

my_clusters = find_point_clusters(analysis_layer, min_features_cluster=10, search_distance=5, search_distance_unit='Kilometers',
output_name="Output_name", context=None, gis=None)

And then it makes sense to use find centroids if those groups could be split apart somehow...

arcgis.features.analysis.find_centroids

0 Kudos
0 Replies