▾
Roads and highways in Singapore are filtered by classification as the map scale changes to reduce loading and visual clutter.
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 and is configured on the
featureReductionproperty of the layer. When set, overlapping features are randomly removed from the view and displayed at scales and camera angles where they no longer overlap nearby features. - Display filters control which features are displayed in the view 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)
FeatureReductionSelection declutters 3D point layers by randomly removing overlapping features. Set the layer’s featureReduction type to selection to enable it.
26 collapsed lines
<!doctype html><html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Thinning - feature reduction by selection (3D)</title>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script>
<style> html, body { height: 100%; margin: 0; }
#cityStyle { background-color: white; text-align: center; padding: 10px 10px 0 10px; } </style> </head>
<body> <arcgis-scene item-id="c6914a1571cd4e209a35019dffe4ba77"> <arcgis-zoom slot="top-left"></arcgis-zoom> <arcgis-navigation-toggle slot="top-left"></arcgis-navigation-toggle> <arcgis-expand slot="bottom-left" expanded> <arcgis-legend></arcgis-legend> </arcgis-expand> <div id="cityStyle" slot="top-right"> <calcite-label layout="inline"> <calcite-checkbox id="declutter" checked></calcite-checkbox> Declutter view </calcite-label> </div> </arcgis-scene>22 collapsed lines
<script type="module"> const viewElement = document.querySelector("arcgis-scene"); const cityStyleElement = document.getElementById("cityStyle");
await viewElement.componentOnReady();
// add functionality on the controls for selection, perspective, callout lines and relative-to-scene elevation mode cityStyleElement.addEventListener("calciteCheckboxChange", (event) => { if (event.target.id === "declutter") { const type = { type: "selection" }; viewElement.map.layers.items.forEach((layer) => { // Tourist attractions layer if (layer.id === "1a10d207999-layer-90") { layer.featureReduction = event.target.checked ? type : null; } }); } }); </script> </body></html>190 collapsed lines
<html> <head> <meta charset="utf-8" /> <title>Thinning - feature reduction by selection (3D)</title> <link rel="stylesheet" href="https://js.arcgis.com/5.2/esri/themes/light/main.css" /> <!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script>
<style> html, body { height: 100%; margin: 0; }
#cityStyle { background-color: white; text-align: center; padding: 10px 10px 0 10px; } </style> </head>
<body> <arcgis-scene> <arcgis-zoom slot="top-left"></arcgis-zoom> <arcgis-navigation-toggle slot="top-left"></arcgis-navigation-toggle> <arcgis-expand slot="bottom-left" expanded> <arcgis-legend></arcgis-legend> </arcgis-expand> <div id="cityStyle" slot="top-right"> <calcite-label layout="inline"> <calcite-checkbox id="declutter" checked></calcite-checkbox> Declutter view </calcite-label> </div> </arcgis-scene>
<script type="module"> const [WebScene, FeatureLayer] = await $arcgis.import([ "@arcgis/core/WebScene.js", "@arcgis/core/layers/FeatureLayer.js", ]);
const viewElement = document.querySelector("arcgis-scene"); const cityStyleElement = document.getElementById("cityStyle");
// Load the webscene with buildings
const webscene = new WebScene({ portalItem: { // autocasts as new PortalItem() id: "711ddecedece4fd88b728bfe4322c22b", }, });
await webscene.load(); webscene.initialViewProperties.viewingMode = "local"; webscene.initialViewProperties.viewpoint.camera = { position: { spatialReference: { wkid: 102100 }, x: 537957.5073656889, y: 5741332.269461036, z: 324.0998252798912, }, heading: 329.6097397312273, tilt: 82.28087566298973, };
viewElement.map = webscene; viewElement.environment = { lighting: { directShadowsEnabled: true, }, };
// verticalOffset shifts the symbol vertically const verticalOffset = { screenLength: 40, maxWorldLength: 200, minWorldLength: 35, };
// Function that automatically creates the symbol for the points of interest function getUniqueValueSymbol(name, color) { return { type: "point-3d", symbolLayers: [ { type: "icon", resource: { href: name, }, size: 20, outline: { color: "white", size: 2, }, }, ],
verticalOffset: verticalOffset,
callout: { type: "line", color: "white", size: 2, border: { color: color, }, }, }; }
const pointsRenderer = { type: "unique-value", field: "Type", uniqueValueInfos: [ { value: "Restaurant", symbol: getUniqueValueSymbol( "https://developers.arcgis.com/javascript/latest/assets/sample-code/visualization-point-styles/Restaurant.avif", "#F97C5A", ), }, { value: "Church", symbol: getUniqueValueSymbol( "https://developers.arcgis.com/javascript/latest/assets/sample-code/visualization-point-styles/Church.avif", "#884614", ), }, { value: "Hotel", symbol: getUniqueValueSymbol( "https://developers.arcgis.com/javascript/latest/assets/sample-code/visualization-point-styles/Hotel.avif", "#56B2D6", ), }, { value: "Park", symbol: getUniqueValueSymbol( "https://developers.arcgis.com/javascript/latest/assets/sample-code/visualization-point-styles/Park.avif", "#40C2B4", ), }, { value: "Museum", symbol: getUniqueValueSymbol( "https://developers.arcgis.com/javascript/latest/assets/sample-code/visualization-point-styles/Museum.avif", "#D13470", ), }, ], };
const pointsLayer = new FeatureLayer({ url: "http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/LyonPointsOfInterest/FeatureServer", title: "Touristic attractions", elevationInfo: { mode: "relative-to-scene", }, renderer: pointsRenderer, outFields: ["*"], screenSizePerspectiveEnabled: true, labelingInfo: [ { labelExpressionInfo: { value: "{Name}", }, symbol: { type: "label-3d", symbolLayers: [ { type: "text", material: { color: "white", }, halo: { size: 1, color: [50, 50, 50], }, size: 10, }, ], }, }, ], });
pointsLayer.featureReduction = { type: "selection", };15 collapsed lines
webscene.add(pointsLayer);
// add functionality on the controls for selection, perspective, callout lines and relative-to-scene elevation mode cityStyleElement.addEventListener("calciteCheckboxChange", (event) => { if (event.target.id === "declutter") { const type = { type: "selection", }; pointsLayer.featureReduction = event.target.checked ? type : null; } }); </script> </body></html>Display filter
A display filter controls which features are visible at each scale, reducing download size for large layers, particularly on mobile devices.
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 to draw all features, it isn’t feasible to load the entire dataset to a browser.
Thinning this data with a display filter 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 the entire layer visibility at scales best suited to the density of the data. This is controlled by the minScale and maxScale properties of the layer.
36 collapsed lines
<html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Thinning - line features</title>
<link rel="stylesheet" href="https://js.arcgis.com/5.2/esri/themes/light/main.css" /> <!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script>
<style> html, body { height: 100%; margin: 0; } </style> </head>
<body> <arcgis-map> <arcgis-zoom slot="top-left"></arcgis-zoom> <arcgis-expand slot="top-right" expanded> <arcgis-legend></arcgis-legend> </arcgis-expand> </arcgis-map>
<script type="module"> const [WebMap, FeatureLayer, reactiveUtils] = await $arcgis.import([ "@arcgis/core/WebMap.js", "@arcgis/core/layers/FeatureLayer.js", "@arcgis/core/core/reactiveUtils.js", ]);
const viewElement = document.querySelector("arcgis-map");
const highwaysLayer = new FeatureLayer({ portalItem: { id: "a9f8d83a69fc4f2c92e5f83f87df6aaf", }, minScale: 1000000, maxScale: 0, });82 collapsed lines
await highwaysLayer.load(); const otherSymbol = highwaysLayer.renderer.defaultSymbol.clone();
highwaysLayer.displayFilterInfo = { mode: "scale", filters: [ { title: "Large highways", minScale: 0, maxScale: 300000, where: "highway IN ('motorway')", }, { title: "Small highways", minScale: 300000, maxScale: 60000, where: "highway IN ('motorway', 'motorway_link', 'trunk', 'trunk_link')", }, { title: "Major roads", minScale: 60000, maxScale: 45000, where: "highway IN ('motorway', 'motorway_link', 'trunk', 'trunk_link', 'primary', 'primary_link')", }, { title: "Roads", minScale: 45000, maxScale: 30000, where: "highway IN ('motorway', 'motorway_link', 'trunk', 'trunk_link', 'primary', 'primary_link')", }, { title: "Smallest roads", minScale: 30000, maxScale: 10000, where: "highway IN ('motorway', 'motorway_link', 'trunk', 'trunk_link', 'primary', 'primary_link', 'secondary', 'secondary_link')", }, { title: "All roads", maxScale: 0, minScale: 10000, }, ], };
viewElement.constraints = { snapToZoom: false, }; viewElement.viewpoint = { rotation: 0, scale: 288895, targetGeometry: { type: "point", spatialReference: { latestWkid: 3857, wkid: 102100, }, x: 11561748.90233894, y: 155241.07522847608, }, }; viewElement.map = new WebMap({ basemap: "gray-vector", layers: [highwaysLayer], });
await viewElement.viewOnReady();
// Show "Other" roads and their legend entry only at 1:10,000 or closer. reactiveUtils.watch( () => viewElement.view.scale <= 10000, (showOther) => { const updatedRenderer = highwaysLayer.renderer.clone(); updatedRenderer.defaultSymbol = showOther ? otherSymbol : null; highwaysLayer.renderer = updatedRenderer; }, { initial: true }, ); </script> </body></html>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 via the displayFilterInfo property of the layer. Simply set the mode of the display filter to scale, then provide an array of scale ranges and SQL where clauses to filter features based on the given scale range.
Notice how each filter is more inclusive of road types as the scale ranges represent larger scales. This means as the user zooms in, they will see more detailed road types. And as they zoom out, the detail will be filtered out.
20 collapsed lines
<!doctype html><html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Thinning - line features</title>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script>
<style> html, body { height: 100%; margin: 0; } </style> </head>
<body> <arcgis-map item-id="cdb4bfa54b3e439e8411b10baae5feb5"> <arcgis-zoom slot="top-left"></arcgis-zoom> <arcgis-expand slot="top-right" expanded> <arcgis-legend></arcgis-legend> </arcgis-expand> </arcgis-map>2 collapsed lines
</body></html>47 collapsed lines
<html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Thinning - line features</title>
<link rel="stylesheet" href="https://js.arcgis.com/5.2/esri/themes/light/main.css" /> <!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script>
<style> html, body { height: 100%; margin: 0; } </style> </head>
<body> <arcgis-map> <arcgis-zoom slot="top-left"></arcgis-zoom> <arcgis-expand slot="top-right" expanded> <arcgis-legend></arcgis-legend> </arcgis-expand> </arcgis-map>
<script type="module"> const [WebMap, FeatureLayer, reactiveUtils] = await $arcgis.import([ "@arcgis/core/WebMap.js", "@arcgis/core/layers/FeatureLayer.js", "@arcgis/core/core/reactiveUtils.js", ]);
const viewElement = document.querySelector("arcgis-map");
const highwaysLayer = new FeatureLayer({ portalItem: { id: "a9f8d83a69fc4f2c92e5f83f87df6aaf", }, minScale: 1000000, maxScale: 0, });
await highwaysLayer.load(); const otherSymbol = highwaysLayer.renderer.defaultSymbol.clone();
highwaysLayer.displayFilterInfo = { mode: "scale", filters: [ { title: "Large highways", minScale: 0, maxScale: 300000, where: "highway IN ('motorway')", }, { title: "Small highways", minScale: 300000, maxScale: 60000, where: "highway IN ('motorway', 'motorway_link', 'trunk', 'trunk_link')", }, { title: "Major roads", minScale: 60000, maxScale: 45000, where: "highway IN ('motorway', 'motorway_link', 'trunk', 'trunk_link', 'primary', 'primary_link')", }, { title: "Roads", minScale: 45000, maxScale: 30000, where: "highway IN ('motorway', 'motorway_link', 'trunk', 'trunk_link', 'primary', 'primary_link')", }, { title: "Smallest roads", minScale: 30000, maxScale: 10000, where: "highway IN ('motorway', 'motorway_link', 'trunk', 'trunk_link', 'primary', 'primary_link', 'secondary', 'secondary_link')", }, { title: "All roads", maxScale: 0, minScale: 10000, }, ], };37 collapsed lines
viewElement.constraints = { snapToZoom: false, }; viewElement.viewpoint = { rotation: 0, scale: 288895, targetGeometry: { type: "point", spatialReference: { latestWkid: 3857, wkid: 102100, }, x: 11561748.90233894, y: 155241.07522847608, }, }; viewElement.map = new WebMap({ basemap: "gray-vector", layers: [highwaysLayer], });
await viewElement.viewOnReady();
// Show "Other" roads and their legend entry only at 1:10,000 or closer. reactiveUtils.watch( () => viewElement.view.scale <= 10000, (showOther) => { const updatedRenderer = highwaysLayer.renderer.clone(); updatedRenderer.defaultSymbol = showOther ? otherSymbol : null; highwaysLayer.renderer = updatedRenderer; }, { initial: true }, ); </script> </body></html>Related samples and resources
API support
The following table describes the geometry and view types that are suited well for each visualization technique.
| 2D | 3D | Points | Lines | Polygons | Mesh | Client-side | Server-side | |
|---|---|---|---|---|---|---|---|---|
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | ||||||
| | | | | | | | |
- Feature reduction selection not supported
- Only by feature reduction selection
- Only by scale-driven filter

