Skip to content

The /SnapToRoads direct request can only be published using configure routing services dialog box from ArcGIS Enterprise portal website, or publish using publish routing services command line utility. Use the following endpoint to access the /SnapToRoads direct request. The {{folderName}} represents the folder in which the services are being published.

GETGETPOST
Use dark colors for code blocksCopy
1
GET https://{{machineName}}/{{serverWebAdaptorName}}/rest/services/{{folderName}}/NetworkAnalysisSync/GPServer/SnapToRoads/execute

The /SnapToRoads direct request can be used to snap a series of GPS track points to the underlying roads. You can return just the snapped points, or lines representing the roads that were traversed. In addition to the geometry, you can have the request return attributes of the roads like the posted speed limit and length in case you need this to perform route adherence.

For example, the following image shows a series of GPS points that were collected while driving a vehicle. The result shows the points snapped to the underlying roads and the roads that were traversed.

 Snap to roads GPS Track

Parameters

NameRequiredTypeDefaultDescription
fstring

The request response format, either json or pjson

tokenstring

An access token with the required privileges.

pointsfeature

Points that you want to snap to the road.

travel_modeobject

The mode of transportation for the analysis provided as a JSON object.

return_linesboolean

false

Whether the request will return output_lines representing the roads traversed.

road_properties_on_snapped_points[string]

Road properties returned on the output_snapped_points output.

road_properties_on_lines[string]

Road properties returned on the output_lines output.

contextobject

Additional settings that affect task operation

overridesstring

For internal use only.

Required parameters

points

Specify the points that you want to snap to the road the vehicle is most likely traveling along. The points can be the GPS points from a navigation device, the tracks captured using ArcGIS Field Maps, or some other set of points that were collected while driving the vehicle.

The distance between the points will affect the performance and final quality of the output. If the points are close together, the algorithm will have a better chance of deducing the probable roads at the expense of processing time. Fewer points will process faster, but may result in the route that was deduced potentially taking different roads.

Show attributes for points

Attributes for points

  • ObjectIDIntegernullable

    The ID of the feature. This field is used to link the output_snapped_points with the input points.

    This field will be used to sequence the points if the location_timestamp field is not present.

  • location_timestampdatetimenullable

    The date and time at which the point was collected. This is the same as the Time field in a GPX file.

    This field will be used to sequence the points if it is available.

  • horizontal_accuracynumber (non-negative)nullable

    The horizontal accuracy of the point measured in meters. This is the same as the HDOP field in a GPX file.

  • speednumber (non-negative)nullable

    The speed of the point in meters per second.

  • coursenumber (non-negative)nullable

    The compass direction of the point in units of 0 to 360 degrees. 0 is due North, 90 is due East and so on.

  • track_idstringnullable

    The ID of the track that the point belongs to. This attribute is used to group points that belong to the same track. You can snap multiple tracks in a single request by assigning unique track IDs to points that belong to different tracks.

    If this field is not present, the algorithm will assume that all points belong to the same track. If track_id is specified for some points and not for others, the ones without a track_id will be unlocated.

Example:

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
64
65
66
67
68
69
70
{
  "features": [
    {
      "attributes": {
        "OBJECTID": 1,
        "location_timestamp": 1704522159000,
        "track_id": "track 1"
      },
      "geometry": {
        "x": -122.43410099956145,
        "y": 37.800155000053394
      }
    },
    {
      "attributes": {
        "OBJECTID": 2,
        "location_timestamp": 1704522171000,
        "track_id": "track 1"
      },
      "geometry": {
Expand

f

The response format.

Use dark colors for code blocksCopy
1
f=json

token

Specify a token that provides the identity of a user that has the permissions to access the service. The security and authentication page provides more information about how an access token can be obtained.

Use dark colors for code blocksCopy
1
"token=<yourToken>"

Optional parameters

travel_mode

Choose the mode of transportation for the analysis. This is the mode of transportation that matches the track data you are analyzing.

The snap to roads algorithms use the travel mode settings when determining the most likely roads that were traveled. For example, if the travel mode restricts travel on express lanes, the algorithms attempt to return roads that are not express lanes. However, in cases where the track clearly indicates the use of an express lane, the algorithms return the express lane regardless of the restriction setting. In other words, the travel mode settings are used as a guideline to influence the snapping behavior, but they may be overridden when the track data does not match those settings.

To learn more about travel modes, see Configure travel modes.

return_lines

Specify whether or not the service will return output_lines representing the roads traversed.

  • true—The output_lines will be returned.
  • false—The output_lines will not be returned.

road_properties_on_snapped_points

Allowed values:

  • oid_Routing_Streets: The ObjectID of the road segment in Routing_Streets feature class the snapped points locate on. It is a unique identifier for the road segment in Routing_Streets feature class.
  • posted_speed_limit_kph: The posted speed limit (in kilometers per hour) of the road segment on which the snapped points are located.
  • posted_speed_limit_mph: The posted speed limit (in miles per hour) of the road segment on which the snapped points are located.
  • posted_speed_limit_mps: The posted speed limit (in meters per second) of the road segment on which the snapped points are located.
  • posted_truck_speed_limit_kph: The posted truck speed limit (in kilometers per hour) of the road segment on which the snapped points are located.
  • posted_truck_speed_limit_mph: The posted truck speed limit (in miles per hour) of the road segment on which the snapped points are located.
  • posted_truck_speed_limit_mps: The posted truck speed limit (in meters per second) of the road segment on which the snapped points are located.

Specify the road properties that the service should return on the output_snapped_points output.

For example: road_properties_on_snapped_points=["posted_speed_limit_kph", "posted_truck_speed_limit_kph"]

road_properties_on_lines

Allowed values:

  • oid_Routing_Streets: The ObjectID of the road segment in Routing_Streets feature class. It is a unique identifier for the road segment in Routing_Streets feature class.
  • length_kilometers: The length (in kilometers) of the road segment.
  • length_miles: The length (in miles) of the road segment.
  • posted_speed_limit_kph: The posted speed limit (in kilometers per hour) of the road segment.
  • posted_speed_limit_mph: The posted speed limit (in miles per hour) of the road segment.
  • posted_speed_limit_mps: The posted speed limit (in meters per second) of the road segment.
  • posted_truck_speed_limit_kph: The posted truck speed limit (in kilometers per hour) of the road segment.
  • posted_truck_speed_limit_mph: The posted truck speed limit (in miles per hour) of the road segment.
  • posted_truck_speed_limit_mps: The posted truck speed limit (in meters per second) of the road segment.

Specify the road properties that the service should return on the output_lines output.

For example: road_properties_on_lines=["length_miles", "length_kilometers"]

context

This parameter contains additional settings that affect task operation, for example, the spatial reference of the output features.

overrides

Response objects

output_snapped_points

This output is always returned. It includes all of the fields from the input specified in the points parameter plus any fields for the properties specified in the road_properties_on_snapped_points parameter. The output also contains following attributes that are either generated or altered by the service.

Show attributes for output snapped points
  • ObjectIDinteger

    The ID of the feature. This field has the same values as the input points if the ObjectID field was passed in. Otherwise, they are sequential numbers starting with 1 and going up through the number of features returned.

  • confidencedouble

    This field defines the confidence level of the computed solution - how likely it is that the computed snapped location is accurate. Its value is between 0 and 1 where 0 means it didn't snap to a road at all and 1 is very confident that the snapping is correct.

  • line_idinteger

    The ObjectID of the line feature in the output_lines. This field is only present if return_lines is specified as true in the input. This field is used to link the output snapped points with the output lines.

output_lines

This output is returned if return_lines is specified as true in the input. It includes fields for the properties specified in the road_properties_on_lines parameter. The output also contains following attributes that are generated by the service.

Show attributes for output lines
  • ObjectIDinteger

    The ID of the feature.

  • track_idstringnullable

    The ID of the track that the line belongs to. This attribute is used to group lines that belong to the same track. This attribute is only applicable if the input points specify track_id attribute.

  • line_typestring enum

    The type of the output line. The possible values are as following:

    • Road: The output line represents a road segment.
    • OffRoad: The output line represents a segment that is not a road or is not known to the routing data. The offroad segments uses straight line to connect the last point before the offroad segment and the first point after the offroad segment, and all the intermediate points are not snapped.
    • Gap: The output line represents a gap between two part of the tracks. This can happen when the tracks are not continuous, typically when the GPS signal is lost. The gap is represented by a straight line between the last point before the gap and the first point after the gap.

usage_cost

This parameter returns the credits used by the analysis.

Example

The following shows an example of the usage_cost parameter in which the analysis generated 9 billable objects (represented by numObjects ) and 4.5 credits were used by the analysis.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
{
  "paramName": "Usage_Cost",
  "dataType": "GPString",
  "value": {
    "numObjects": 9,
    "credits": 4.5
  }
}

Examples

To use the snap to roads request, you need to pass in a set of point features to which you want to snap to roads. In addition to the point geometry, you can include additional GPS-related data to better guide the snapping. You can also specify if you want to return attributes from the underlying roads and if you want to add them on the output points or lines returned.

Below is an example of a request to the Snap to Roads service and a few sample responses:

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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
POST https://{{machineName}}/{{serverWebAdaptorName}}/rest/services/Routing/NetworkAnalysisSync/GPServer/SnapToRoads/execute HTTP/1.1
Content-Type: application/x-www-form-urlencoded

token=<ACCESS_TOKEN>
&f=json
&points={
  "features": [
    {
      "attributes": {
        "OBJECTID": 1,
        "location_timestamp": 1704522159000
      },
      "geometry": {
        "x": -122.43410099956145,
        "y": 37.800155000053394
      }
    },
    {
      "attributes": {
        "OBJECTID": 2,
Expand

Service limits

The table below lists the limits that apply to this service.

Limit descriptionLimit value

The maximum number of point or line features that can be returned.

100,000

The maximum time a client can use the Snap to Roads service.

10 minutes

The limits can be configured by following the steps below:

  1. Open Server Manager for the ArcGIS Server site that contains the snap to roads service and sign in. If you need help with this step, see Log in to Manager.

  2. Click Services > Manage Services.

  3. In the Manage Services module, locate NetworkAnalysisSync geoprocessing service and click Edit Service.

    If you don't see the service under the Routing folder, it may be located within another folder under the Site (root) >.

  4. Click the Parameters option and change the limit for the number of records returned by the service by editing the value in Maximum Number of Records Returned by Server text box.

  5. Click the Pooling option and change the maximum time the service can be used by editing the value in the The maximum time a client can use a service text box.

  6. Click Save and Restart to apply your edits and restart the service.

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