Item page
CodePen
Sandbox Download

Fatal car crashes in 2017 represented as a continuous heatmap, with yellow indicating higher concentrations of crashes.

What is a heatmap?

A Heatmap renders point features as a raster surface, emphasizing areas with a higher density of points along a continuous color ramp.

Why are heatmaps useful?

Heatmaps can be used as an alternative to clustering, opacity, and bloom to visualize overlapping point features. Unlike these alternative techniques for visualizing density, you can use a heatmap to weight the density of points based on a data value. This may reveal a different pattern than density calculated using location alone.

Location-only heatmapData-weighted heatmap
classed with no label
Figure : Density of car crashes that resulted in a fatality (2017). Yellow areas indicate the highest density of crash incidents.
classed with no label
Figure : Density of fatal car crashes involving drunk drivers (2017). Yellow areas indicate the highest density of crash incidents that involved drunk drivers.

How a heatmap works

Heatmaps are created by setting a HeatmapRenderer instance to the renderer property of the layer. The HeatmapRenderer has several key properties. The radius determines the area of influence surrounding a point. For example, if you set a radius of 10 pixels, each pixel within 10 pixels of a single point will be assigned a density value. The pixel directly on top of the point will have the highest density. Smaller density values are assigned to pixels surrounding the point inversely proportional to the distance from the point. Pixels on the screen that fall outside that 10-pixel radius of all points will have a density value of 0.

The density value of each pixel accumulates based on its proximity to multiple points. For example, a pixel within 10px of 10 points, will have a higher density value than pixels within 10px of only one point.

The colorStops in the renderer determine how to colorize pixels based on the ratio of a pixel’s density value to the maxDensity (i.e. pixel density / maxDensity). Pixels with a density value at or above the maxDensity have a density ratio of 1 and should be assigned the brightest color since these represent the hottest areas. The larger the maxDensity, the fewer hot spots will exist in the map.

Examples

Location heatmap

Apply a HeatmapRenderer to a point layer and configure its properties using the guidelines above.

Item page
CodePen
Sandbox Download
Fatal car crashes in 2017 are rendered as a continuous heatmap; adjust radius and maximum density to see how the surface changes.
Heatmap - location
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>Heatmap - location</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="44b71a9e84e943459e2745f1a179bc79">
<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>

Data-weighted heatmap

When a field is specified, each pixel’s density is multiplied by the data value, so you need to adjust the maxDensity accordingly.

Item page
CodePen
Sandbox Download
Fatal car crashes involving drinking are weighted by the number of drinking drivers to reveal where more drinking drivers were involved.
Heatmap - data-weighted
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>Heatmap - data-weighted</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="0196deeb47fc424da700e19c015c8bba">
<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>

Scale-dependent Heatmap

Dynamic heatmaps are only visually appropriate at a few scale levels. As the user zooms out, the heatmap will always appear hotter. As the user zooms in, the heatmap will appear colder. To prevent the user from viewing a heatmap that is too hot, you can set a minScale on the layer or as a view constraint.

As the user zooms in, the heatmap becomes irrelevant. Therefore, you should set a watch on the view to toggle the layer’s heatmap to a simple renderer representing individual point locations.

Map Viewer does not support switching a layer's renderer by scale or custom zoom constraints. As a workaround, duplicate the layer and assign heatmap and point styles with complementary visible scale ranges. These hide the heatmap outside useful scales without restricting zoom.
Item page
CodePen
Sandbox Download
Fraud incidents in San Diego switch from a heatmap to individual points as you zoom in.
Heatmap - scale-dependent
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>Heatmap - scale-dependent</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;
}
#note {
padding: 10px;
width: 300px;
font-size: var(--calcite-font-size);
}
</style>
</head>
<body>
<arcgis-map item-id="96d380aa84fb43ebbfe2fdc862e7818e">
<arcgis-zoom slot="top-left"></arcgis-zoom>
<arcgis-expand slot="top-left" expand-icon="question" expand-tooltip="How to use this sample" expanded>
<div id="note">As you zoom in, the style will switch from a heatmap to individual points.</div>
</arcgis-expand>
<arcgis-legend slot="bottom-left"></arcgis-legend>
</arcgis-map>
2 collapsed lines
</body>
</html>

Static heatmaps

Static heatmaps allow you to persist the visual density of a heatmap from one scale across all scale levels. As the user zooms in and out, the heatmap will consistently show the same hot spots in the view.

As the user zooms in, the heatmap becomes irrelevant, so you may want to set a constraint on the MapView to prevent overzooming.

Item page
CodePen
Sandbox Download
New York City tree density remains visually consistent as the map scale changes.
Heatmap - static
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>Heatmap - static</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="7e8b2cebe5fe4699b446b4de7c71672d">
<arcgis-zoom slot="top-left"></arcgis-zoom>
<arcgis-expand slot="bottom-left" expanded>
<arcgis-legend></arcgis-legend>
</arcgis-expand>
</arcgis-map>
2 collapsed lines
</body>
</html>

Faded heatmaps

Configuring a heatmap renderer with proper density values can be difficult, especially when the starting view scale is unknown. The heatmap smart mapping renderer creator helps generate a suggested heatmap given the current view scale and background color.

It also automatically fades colors from dense areas (full opacity) to sparse areas (high transparency). The fading of colors helps establish a fuzzy boundary, which is often more appropriate than a hard edge for heatmap visualizations.

Item page
CodePen
Sandbox Download
A heatmap of Chicago homicides fades sparse areas into the background.
Heatmap - Chicago Homicides (Faded)
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>Heatmap - Chicago Homicides (Faded)</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="92cb5a404e21472aad7bc9900caa3055">
<arcgis-zoom slot="top-left"></arcgis-zoom>
<arcgis-expand slot="bottom-left" expanded>
<arcgis-legend></arcgis-legend>
</arcgis-expand>
</arcgis-map>
2 collapsed lines
</body>
</html>

API support

The following table describes the geometry and view types that are suited well for each visualization technique.

  • Full support
  • Partial support
  • No support
2D3DPointsLinesPolygonsMeshClient-sideServer-side
  1. Feature reduction selection not supported
  2. Only by feature reduction selection
  3. Only by scale-driven filter