Skip to content

Learn how to find elevation values for points along a path in New Zealand's South Island.

Prerequisites

You need an ArcGIS Location Platform account.

ArcGIS Online and ArcGIS Enterprise accounts are not supported.

Steps

Create a new app

  1. Open a terminal and create a new folder for your project.

    Use dark colors for code blocksCopy
    1
    2
    mkdir find-the-elevations-of-multiple-points
    cd find-the-elevations-of-multiple-points

  2. Initialize a new Node.js project. This creates a package.json file.

    Use dark colors for code blocksCopy
    1
    npm init
  3. Install the required packages.

    Use dark colors for code blocksCopy
    1
    npm install @esri/arcgis-rest-request @esri/arcgis-rest-elevation --save

  4. Create a new JavaScript file named index.js.

    Use dark colors for code blocksCopy
    1
    touch index.js

Get an access token

Create a new API key credential with the correct privileges to get an access token.

  1. Go to the Create an API key tutorial and create an API key with the following privilege(s):
    • Privileges:
      • Location services > Elevation service
  2. Copy the API key access token to your clipboard when prompted.

Make a request

  1. Open your index.js file and import the packages.

    index.js
    Use dark colors for code blocks
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    
    import { ApiKeyManager } from "@esri/arcgis-rest-request";
    import { findElevationAtManyPoints } from "@esri/arcgis-rest-elevation";
    
    
  2. Paste in your access token.

    index.js
    Use dark colors for code blocks
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    
    import { ApiKeyManager } from "@esri/arcgis-rest-request";
    import { findElevationAtManyPoints } from "@esri/arcgis-rest-elevation";
    
    const accessToken = "YOUR_ACCESS_TOKEN";
    const authentication = ApiKeyManager.fromKey(accessToken);
    
    
  3. Make a request to find the elevations of multiple points along New Zealand's South Island and print the results.

    index.js
    Use dark colors for code blocks
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    
    import { ApiKeyManager } from "@esri/arcgis-rest-request";
    import { findElevationAtManyPoints } from "@esri/arcgis-rest-elevation";
    
    const accessToken = "YOUR_ACCESS_TOKEN";
    const authentication = ApiKeyManager.fromKey(accessToken);
    
    findElevationAtManyPoints({
      coordinates: [
        [1.2783, 51.1102], // Dover, UK
        [1.3507, 51.0883],
        [1.4206, 51.0524],
        [1.4939, 51.0162],
        [1.5978, 50.9827],
        [1.7302, 50.9387] // Calais, France
      ],
      authentication
    }).then((response) => {
      console.log(JSON.stringify(response, null, 2));
    });
  4. Save the file, then run it from the terminal.

    Use dark colors for code blocksCopy
    1
    node index.js

You should now see the results printed in your console.

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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{
  "result": {
    "points": [
      {
        "x": 1.2783,
        "y": 51.1102,
        "z": 85.4,
        "spatialReference": {
          "wkid": 4326,
          "vcsWkid": 105700
        }
      },
      {
        "x": 1.3507,
        "y": 51.0883,
Expand

What's next?

Learn how to use additional location services in these tutorials:

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