PointCloudLayer - toggle renderers

Point cloud data can be visualized in the browser using the PointCloudLayer. The visualization of each point (its color and size) is defined by a renderer. There are four renderer types that may be applied to point cloud data:

These renderers can be created manually using the API defined in the documentation, or generated using the Smart Mapping APIs. There are three renderer creator methods that simplify the renderer creation process for PointCloudLayer:

This sample shows how to call each of these methods and apply different renderers to the PointCloudLayer. The renderer used for the visualization depends on a given field name. Typical field names for point clouds include ELEVATION, RGB, CLASS_CODE, and INTENSITY. For example, rather than map colors to a long list of class codes in a PointCloudUniqueValueRenderer, you can simply call the createPCClassRenderer() method to generate the standard colors for the data based on the CLASS_CODE field:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
const layer = new PointCloudLayer({
  url: "https://tiles.arcgis.com/tiles/V6ZHFr6zdgNZuVG0/arcgis/rest/services/BARNEGAT_BAY_LiDAR_UTM/SceneServer"
});

// generates colors for visualizing each class code
typeRendererCreator
  .createPCClassRenderer({
    layer: layer,
    field: "CLASS_CODE"
  })
  .then((response) => {
    // set the renderer on the input layer
    layer.renderer = response.renderer;
  });

This sample uses a custom function to generate the appropriate renderer based on a given field name.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// stores generated renderers to avoid making service
// calls for the same renderer multiple times
const renderersByField = {
  RGB: null,
  CLASS_CODE: null,
  ELEVATION: null,
  INTENSITY: null
};

function getRenderer(fieldName) {
  // If the renderer is already generated, then return it
  if (renderersByField[fieldName]) {
    return promiseUtils.resolve(renderersByField[fieldName]);
  }

  // Store the generated renderer in a predefined object in
  // case it is requested in the future and return the renderer
  function responseCallback(response) {
    renderersByField[fieldName] = response.renderer;
    return response.renderer;
  }

  if (fieldName === "RGB") {
    return colorRendererCreator
      .createPCTrueColorRenderer({
        layer: pcLayer
      })
      .then(responseCallback);
  }
  if (fieldName === "CLASS_CODE") {
    return typeRendererCreator
      .createPCClassRenderer({
        layer: pcLayer,
        field: fieldName
      })
      .then(responseCallback);
  }
  if (fieldName === "ELEVATION" || "INTENSITY") {
    return colorRendererCreator
      .createPCContinuousRenderer({
        layer: pcLayer,
        field: fieldName
      })
      .then(responseCallback);
  }
}

Additional resources

See the following samples to learn how to manually create the renderers listed above rather than using the Smart Mapping APIs to do so:

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.