Skip to content
GuidesBlogPlaygroundDashboard

Match GPS coordinates to the road network

map_match.match(MapMatchMatchParams**kwargs) -> MapMatchResult
POST/api/v1/map-match

Match GPS coordinates to the road network

ParametersExpand Collapse
coordinates: Iterable[Coordinate]

GPS coordinates to match, in order of travel (max 50 points)

lat: float

Latitude in decimal degrees (-90 to 90)

maximum90
minimum-90
lng: float

Longitude in decimal degrees (-180 to 180)

maximum180
minimum-180
radiuses: Optional[Iterable[float]]

Search radius per coordinate in meters. Must have the same length as coordinates or be omitted entirely. Default: 50m per point.

ReturnsExpand Collapse
class MapMatchResult:

Map matching result as a GeoJSON FeatureCollection. Each Feature is a snapped tracepoint. The top-level matchings array contains the matched sub-routes connecting consecutive tracepoints.

features: List[Feature]

Snapped tracepoint Features in input order

geometry: GeoJsonGeometry

GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints.

coordinates: Union[List[float], List[List[float]], List[List[List[float]]], List[List[List[List[float]]]]]

Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc.

One of the following:
List[float]

[longitude, latitude] or [longitude, latitude, elevation]

List[List[float]]

Array of [lng, lat] positions

List[List[List[float]]]

Array of linear rings / line strings

List[List[List[List[float]]]]

Array of polygons

type: Literal["Point", "LineString", "Polygon", 3 more]

Geometry type

One of the following:
"Point"
"LineString"
"Polygon"
"MultiPoint"
"MultiLineString"
"MultiPolygon"
properties: FeatureProperties
distance_m: Optional[float]

Distance from the original GPS point to the snapped point in meters

edge_id: Optional[int]

Road edge ID the point was snapped to

matchings_index: Optional[int]

Index into the matchings array indicating which matching sub-route this point belongs to

name: Optional[str]

Road name at the snapped point

original: Optional[List[float]]

Original GPS coordinate as [lng, lat]

waypoint_index: Optional[int]

Index of this tracepoint in the original coordinates array

type: Literal["Feature"]
matchings: List[Dict[str, object]]

Matched sub-routes. Each matching connects a contiguous sequence of tracepoints that could be matched to roads.

type: Literal["FeatureCollection"]

Match GPS coordinates to the road network

import os
from plaza import Plaza

client = Plaza(
    api_key=os.environ.get("PLAZA_API_KEY"),  # This is the default and can be omitted
)
map_match_result = client.map_match.match(
    coordinates=[{
        "lat": 48.8566,
        "lng": 2.3522,
    }, {
        "lat": 48.857,
        "lng": 2.353,
    }, {
        "lat": 48.8575,
        "lng": 2.354,
    }],
)
print(map_match_result.features)
{
  "features": [
    {
      "geometry": {
        "coordinates": [
          2.3522,
          48.8566
        ],
        "type": "Point"
      },
      "properties": {
        "distance_m": 0,
        "edge_id": 0,
        "matchings_index": 0,
        "name": "name",
        "original": [
          0,
          0
        ],
        "waypoint_index": 0
      },
      "type": "Feature"
    }
  ],
  "matchings": [
    {
      "foo": "bar"
    }
  ],
  "type": "FeatureCollection"
}
Returns Examples
{
  "features": [
    {
      "geometry": {
        "coordinates": [
          2.3522,
          48.8566
        ],
        "type": "Point"
      },
      "properties": {
        "distance_m": 0,
        "edge_id": 0,
        "matchings_index": 0,
        "name": "name",
        "original": [
          0,
          0
        ],
        "waypoint_index": 0
      },
      "type": "Feature"
    }
  ],
  "matchings": [
    {
      "foo": "bar"
    }
  ],
  "type": "FeatureCollection"
}