API

Every page is also an API. Same URL, JSON instead of HTML.

Getting JSON

You get JSON when any of these is true:

$ curl latlng.tools/51.5,-0.12/to/40.71,-74.0
{"from":[51.5,-0.12],"to":[40.71,-74],"distance_km":5571.758,...}

Conventions

Endpoints

/:lat,:lng

A point in every format: DMS, UTM, MGRS, geohash, plus code, H3, tile, time zone and elevation.

curl 'latlng.tools/51.5074,-0.1278'

Returns: lat, lng, formats{decimal, dms, ddm, utm, mgrs, geohash, pluscode, h3, tile, geojson, wkt}, utm, timezone, elevation

Try it

/:a/to/:b

Great-circle distance, bearings and midpoint.

curl 'latlng.tools/51.5074,-0.1278/to/40.7128,-74.006'

Returns: from, to, distance_km, distance_mi, distance_nmi, bearing_initial, bearing_final, compass_initial, midpoint

Try it

/:point/sun

Sunrise, sunset, golden hour and twilight (add ?date=YYYY-MM-DD).

curl 'latlng.tools/51.5074,-0.1278/sun'

Returns: point, date, timezone, utc_offset, times{…}, utc{…}, day_length_minutes, position

Try it

/:point/antipode

The opposite side of the Earth.

curl 'latlng.tools/51.5074,-0.1278/antipode'

Returns: point, antipode

Try it

/:point/tile/:z

The slippy-map tile containing a point.

curl 'latlng.tools/51.5074,-0.1278/tile/12'

Returns: tile{z, x, y}, bbox, center, quadkey, tms_y, parent, children, point

Try it

/:point/h3/:res

The H3 cell containing a point.

curl 'latlng.tools/51.5074,-0.1278/h3/7'

Returns: point, cell, resolution, center, boundary, area_km2, pentagon, parent, children

Try it

/geohash/:hash

Decode a geohash: bounds, centre, neighbours.

curl 'latlng.tools/geohash/gcpvj0e'

Returns: hash, precision, center, bbox, error, parent, neighbours

Try it

/tile/:z/:x/:y

Tile bounds, quadkey, parent and children.

curl 'latlng.tools/tile/12/2046/1362'

Returns: tile{z, x, y}, bbox, center, quadkey, tms_y, parent, children

Try it

/h3/:cell

H3 cell boundary, area, parent and children.

curl 'latlng.tools/h3/87195da49ffffff'

Returns: cell, resolution, center, boundary, area_km2, pentagon, parent, children

Try it

/pluscode/:code

Decode an Open Location Code.

curl 'latlng.tools/pluscode/9C3XGV4C+XV'

Returns: code, length, bbox, center

Try it

/dms/:dms

Parse degrees, minutes and seconds, and go to the point.

curl 'latlng.tools/dms/51°30'26"N 0°7'40"W'

Try it

/epsg/:code

A coordinate reference system, with a converter (?x=&y= or ?lat=&lng=).

curl 'latlng.tools/epsg/27700?lat=51.5007&lng=-0.1246'

Returns: code, name, kind, units, area, bounds, proj4, source, conversion

Try it

/bbox

Draw a bounding box and copy it as [w,s,e,n], WKT, GeoJSON, Overpass and more.

GET /bbox?b=west,south,east,north

Returns: bbox, center, crosses_antimeridian, area_km2, width_km, height_km, formats{…}

/polyline

Decode or encode Google / OSRM encoded polylines.

GET /polyline?p=ENCODED[&precision=6]  or  ?points=lat,lng;lat,lng

Returns: encoded, precision, count, points, length_km, bbox

/geojson

Paste or drop GeoJSON to view, validate and fix it (winding order, precision).

curl --data-binary @file.geojson latlng.tools/geojson[?precision=6]

Returns: valid, issues[{level, path, message, fix}], stats, fixed

/gpx

Drop a GPX file to see the route, distance and elevation profile.

curl --data-binary @track.gpx latlng.tools/gpx[?geojson=1]

Returns: name, tracks, routes, waypoints, points, distance_km, elevation, start_time, end_time, duration_s, bbox, profile

/here

Where am I? Your location in every format.

curl 'latlng.tools/here'

Try it

/random

A random point on land.

curl 'latlng.tools/random'

Returns: point, path

Try it

/:point/og.png, /:a/to/:b/og.png

1200×630 PNG map previews, used for link unfurls.