Roads and highways in Singapore. Zoom in and out to view how features are thinned based on highway classification. Only larger, more traveled highways display at small scales. This reduces the initial download size and declutters the visualization.
What is thinning?
Thinning is a method of decluttering the view by removing features that overlap one another. This is helpful when many features overlap and you want to display uncluttered data, but don't necessarily need to communicate its density.
How thinning works
There are a couple of approaches to thinning:
Feature reduction by selection only applies to point layers in 3D scenes. Feature reduction selection is configured on the featureReduction property of point layers. When set, overlapping features are randomly removed from the view and displayed at scales and camera angles where they no longer overlap nearby features.
Scale-driven filter is the process of controlling which features are downloaded to the client based on the view scale. This is useful for reducing the download size of large layers and improving the visualization, particularly for mobile devices.
Examples
Feature reduction by selection (3D)
The following example demonstrates how to declutter the view by randomly removing overlapping features. This is controlled using the FeatureReductionSelection option on point layers in 3D scenes. Simply set the featureReduction type on the layer to selection and features will be thinned automatically.
Points of interest in Lyon, France. Thinning helps declutter the view to make it easier for users to navigate a scene. Uncheck the box in the top right corner to compare the cluttered view with the decluttered view. Zoom in and out to see how feature reduction selection affects the visualization.
This example demonstrates how to control which features are downloaded to the client based on the view scale. This is useful for reducing the download size of large layers, particularly for mobile devices.
Roads and highways in Singapore. Zoom in and out to view how features are thinned based on highway classification. Only larger, more traveled highways display at small scales. This reduces the initial download size and declutters the visualization.
For example, the OpenStreetMap Asia highways layer contains more than 46 million high resolution line features with more than 20 attributes. Since this layer requires several gigabytes of memory, it isn't feasible to load the entire dataset to a browser.
Thinning this data can significantly improve the initial download size, and the visualization.
_
Thinning
No thinning
Initial download size
141kB (27.8kB compressed)
12.2MB (2.1MB compressed)
Preview
First, you should set scale visibility constraints to restrict layer visibility at scales best suited given the density of the data. This is controlled by the minScale and maxScale properties of the layer.
While this will prevent users from loading unreasonable amounts of data to the browser, it still may not be aggressive enough, especially for mobile devices. You can further reduce download size by filtering features dynamically by updating the layer's definitionExpression as the view's scale changes.
This snippet shows how you can define definition expressions (i.e. SQL where clauses) to apply to the layer when the user zooms to certain scales. Notice how this allows you to establish a priority for display. For example, only the largest motorways are displayed at the smallest scale. As the user progressively zooms in, more highways load in the view based on their size classification. This ensures only the minimum data required by users is downloaded to the view, effectively thinning it.