ElevationSampler

Class: esri/layers/support/ElevationSampler
Since: ArcGIS API for JavaScript 4.7

A cache of elevation values created from an elevation service or the GroundView used for synchronously querying elevation information for geometries. This class does not have a constructor. You can create an instance of this class by using ElevationLayer.createElevationSampler() or Ground.createElevationSampler() methods. The elevation sampler created from the Ground will sample data from the first elevation layer that has data available. To control the layer used for elevation sampling and the sampling resolution, use ElevationLayer.createElevationSampler().

map.ground.load()
  .then(function() {
    // create an elevation sampler from a given extent
    return view.map.ground.createElevationSampler(extent);
  })
  .then(function(elevationSampler) {
    // use the elevation sampler to get z-values for a point, multipoint or polyline geometry
    var zEnrichedGeometry = elevationSampler.queryElevation(geometry);
  });
});

An instance of this class is also available in GroundView.elevationSampler. This can be used when the elevation values need to reflect the elevation currently displayed in the view.

var elevationSampler = view.groundView.elevationSampler;
// listen for elevation changes in the view
elevationSampler.on('changed', function() {
  // enrich geometry with z-values from the elevation displayed in the view
  var zEnrichedGeometry = elevationSampler.queryElevation(point);
});
See also:

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
NameTypeSummaryClass
Object

The minimum and maximum resolution of the data in the sampler.

more details
more detailsElevationSampler
Extent

The extent within which the sampler can be queried.

more details
more detailsElevationSampler
Number

The value that is used to represent areas where there is no data available.

more details
more detailsElevationSampler

Property Details

demResolutionObjectreadonly

The minimum and maximum resolution of the data in the sampler.

Properties:
min Number

The minimum resolution.

max Number

The maximum resolution.

extentExtentreadonly
Since: ArcGIS API for JavaScript 4.9

The extent within which the sampler can be queried.

noDataValueNumberreadonly
Since: ArcGIS API for JavaScript 4.9

The value that is used to represent areas where there is no data available.

Method Overview

NameReturn TypeSummaryClass
Object

Registers an event handler on the instance.

more details
more detailsElevationSampler
Point|Multipoint|Polyline

Query elevation for a Point, Polyline or Multipoint geometry.

more details
more detailsElevationSampler

Method Details

on(type, handler?){Object}

Registers an event handler on the instance. Call this method to hook an event with a listener. See the Events summary table for a list of listened events.

Parameters:

The name of the event or the events to listen for.

handler? Function

The function to call when the event is fired, if modifiers were specified.

Returns:
TypeDescription
ObjectReturns an event handler with a remove() method that can be called to stop listening for the event.
PropertyTypeDescription
removeFunctionWhen called, removes the listener from the event.
See also:
Example:
view.groundView.elevationSampler.on("changed", function(evt) {
 console.log("elevation has changed");
});
queryElevation(geometry){Point|Multipoint|Polyline}

Query elevation for a Point, Polyline or Multipoint geometry. A query will return a new geometry for which the z-values for each coordinate in the geometry are obtained from the elevation sampler. If the geometry used for the query is outside of the elevation sampler extent, then the returned geometry has 0 as z-values.

Parameter:

The geometry to use for sampling elevation data.

Returns:
TypeDescription
Point | Multipoint | PolylineThe sampled geometry.

Event Overview

NameTypeSummaryClass

Fires when the data in the sampler has changed.

more details
more detailsElevationSampler

Event Details

changed

Fires when the data in the sampler has changed. This event is only relevant for dynamic elevation samplers such as the elevation sampler on the GroundView.

Example:
view.groundView.elevationSampler.on("changed", function(evt) {
 console.log("elevation has changed");
});

API Reference search results

NameTypeModule
Loading...