Geospatial
Distance to nearest point on segment API
Finds the nearest point on a finite great-circle segment to a query point, returning the distance, the nearest coordinate, the parametric position t (0..1), and whether the foot of the perpendicular is clamped to an endpoint. Answers 'What is the closest point on this line segment?', 'How far is this point from a finite path edge?'.
Price$0.06per request
MethodPOST
Route/v1/geo/point-to-segment
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
geogispoint-to-segmentnearest-pointdistanceprojectionsnap-to-linepolylinerouting
API URL
Integration docshttps://x402.hexl.dev/v1/geo/point-to-segmentExample request
{
"point": {
"latitude": 51,
"longitude": 1
},
"segStart": {
"latitude": 51.5074,
"longitude": -0.1278
},
"segEnd": {
"latitude": 48.8566,
"longitude": 2.3522
}
}Example response
{
"point": {
"latitude": 51,
"longitude": 1
},
"segStart": {
"latitude": 51.5074,
"longitude": -0.1278
},
"segEnd": {
"latitude": 48.8566,
"longitude": 2.3522
},
"nearestPoint": {
"latitude": 50.815628,
"longitude": 0.519399
},
"distanceKm": 39.444204,
"distanceMeters": 39444.204,
"t": 0.260967,
"clamped": "interior",
"interpretation": "Nearest point on the segment is 39.444 km away at parameter t=0.261 (an interior point)."
}Input schema
{
"type": "object",
"required": [
"point",
"segStart",
"segEnd"
],
"properties": {
"point": {
"type": "object",
"properties": {
"latitude": {
"type": "number"
},
"longitude": {
"type": "number"
}
},
"examples": [
{
"latitude": 51,
"longitude": 1
}
]
},
"segStart": {
"type": "object",
"properties": {
"latitude": {
"type": "number"
},
"longitude": {
"type": "number"
}
},
"examples": [
{
"latitude": 51.5074,
"longitude": -0.1278
}
]
},
"segEnd": {
"type": "object",
"properties": {
"latitude": {
"type": "number"
},
"longitude": {
"type": "number"
}
},
"examples": [
{
"latitude": 48.8566,
"longitude": 2.3522
}
]
}
}
}Output schema
{
"type": "object",
"additionalProperties": true
}