Data API

Analysis

Analysis

analyzeGeometry classifies an existing line: it segments the geometry by surface (paved, gravel, dirt, and so on), by way type (path, track, footway, and so on), and by slope angle. Every routing result already carries this analysis under route.analysis; call analyzeGeometry directly when you have a geometry from elsewhere, for example a GPX track or a user-drawn line, and want the same breakdown.

All coordinates are [longitude, latitude] in WGS 84.

ActivityAPI valueWire form
Hiking and trail runningHIKING_AND_TRAILhikingandtrail
RunningRUNNINGrunning
Backcountry skiingBACKCOUNTRY_SKIINGbackcountryskiing
Ski touringSKI_TOURINGskitouring
Cross-country skiingCROSS_COUNTRY_SKIINGcrosscountryskiing
Snowshoe walkingSNOWSHOE_WALKINGsnowshoewalking
Gravel bikingGRAVEL_BIKEgravelbike
Mountain bikingMOUNTAIN_BIKEmountainbike
Road cyclingROAD_CYCLINGroadcycling

Each activity routes on a profile tuned to its terrain and movement style. The GraphQL ActivitySlug enum uses the uppercase value; the Tile and REST APIs use the lowercase, underscore-free wire form.

analyzeGeometry

Input

analyzeGeometry(input: AnalyzeGeometryInput!)

activity

ActivitySlug!

required

Activity to analyze for. Selects the profile used to interpret way and surface suitability.

coordinates

[[Float!]!]!

required

Ordered list of [longitude, latitude] pairs forming the geometry.

Example

query AnalyzeGeometry($input: AnalyzeGeometryInput!) {
  analyzeGeometry(input: $input) {
    surfaceInfo {
      fromIndex
      toIndex
      value
    }
    waytypeInfo {
      fromIndex
      toIndex
      value
    }
    slopeInfo {
      fromIndex
      toIndex
      value
    }
  }
}

Response

GeometryAnalysis returns three lists of segments. Each segment references a range of the input coordinates by index, so you can map a classification back onto the exact part of the line it covers.

surfaceInfo

[SurfaceInfo!]!

Surface-type segments. Each entry has fromIndex, toIndex, and a value of SurfaceType (for example ASPHALT, GRAVEL, DIRT).

waytypeInfo

[WaytypeInfo!]!

Way-type segments. Each entry has fromIndex, toIndex, and a value of WaytypeType (for example PATH, TRACK, FOOTWAY).

slopeInfo

[SlopeInfo!]!

Slope segments. Each entry has fromIndex, toIndex, and a value slope angle in degrees. Positive is uphill, negative is downhill.

The fromIndex and toIndex of each segment are inclusive indices into the coordinates array you sent. See routing for the same analysis attached to computed routes, and the playground for the full SurfaceType and WaytypeType value lists.

Next steps