Skip to Content
BuddyGeoDocs

Coordinate order

Latitude comes first in request parameters, spreadsheets and every human-facing field. GeoJSON puts longitude first.

Swapped coordinates are the most common reason a lookup lands in the wrong place or is rejected. BuddyGeo follows one rule everywhere a person types or reads a coordinate, and the GeoJSON standard wherever GeoJSON is produced.

The rule

WhereOrderExample for the CN Tower
Query parametersNamed, so order does not matter: lat and lonlat=43.6426&lon=-79.3871
Pasted pairs, playground inputs, logslatitude, longitude43.6426, -79.3871
JSON responses (query, result.location)Named fields lat and lon{ "lat": 43.642196, "lon": -79.386628 }
result.bounding_box[south, north, west, east][43.641657, 43.642735, -79.387373, -79.385883]
GeoJSON geometry[longitude, latitude][-79.386628, 43.642196]

All coordinates are WGS84 decimal degrees. Latitude runs from -90 to 90, longitude from -180 to 180. South and west are negative.

GeoJSON is the exception

GeoJSON (RFC 7946) orders positions as [longitude, latitude], the opposite of what people usually write. The GeoJSON view of the reverse playground and any GeoJSON you build from a response follow the standard:

{
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [-79.386628, 43.642196]
  },
  "properties": {
    "formatted": "290 Bremner Boulevard, Toronto, ON M5V 3L9, Canada"
  }
}

If you convert a BuddyGeo result into GeoJSON yourself, write [result.location.lon, result.location.lat].

How swapped values are caught

  • Out-of-range latitude. A latitude outside -90 to 90 is rejected with 400 invalid_coordinates. When the longitude you sent would fit as a latitude, the message says the two may be swapped. Tokyo Tower with its values exchanged:

    curl "https://api.buddygeo.com/v1/reverse?lat=139.7454&lon=35.6586" \
      -H "X-API-Key: YOUR_API_KEY"

    The error object of the response:

    {
      "code": "invalid_coordinates",
      "message": "Latitude 139.7454 is outside -90 to 90. Latitude and longitude may be swapped.",
      "next_step": "Send lat between -90 and 90 and lon between -180 and 180 as decimal degrees, latitude first.",
      "field": "lat"
    }
  • Swaps that stay in range are not errors. lat=-79.3871&lon=43.6426 is the CN Tower pair exchanged, and it is also a valid point in Antarctica. The API cannot know which one you meant, so it answers for the point you sent: nothing is mapped there, result is null and no credit is charged. If a result is null where you expected a city, check the order first.

  • Spreadsheets. The bulk wizard inspects the mapped columns and warns when the values strongly suggest that latitude and longitude are swapped. The swapped-columns sample shows the warning.

  • The map. In the playground the submitted point and the returned point are drawn separately. A marker in the ocean or on the wrong continent is the quickest signal.

Accepted input formats

Human inputs (the playground field, spreadsheet cells) accept:

  • 43.6426, -79.3871, 43.6426 -79.3871 or 43.6426;-79.3871
  • A decimal comma in a single cell, such as 43,6426
  • A trailing degree sign, such as 43.6426°

Degrees-minutes-seconds (43°38'33"N) and hemisphere letters are not parsed: convert them to signed decimal degrees first.

Open in the app

On this page