Convert an OSGB36 easting and northing (British National Grid) to WGS84 latitude and longitude.
https://api.getthedata.com/bng2latlong/[easting]/[northing]
The default response format is JSON, but you can request XML by adding /xml
to the end of your request URL:
https://api.getthedata.com/bng2latlong/[easting]/[northing]/xml
Fieldname | Description |
---|---|
status | ok or error. |
error | Where status=error an error message will be provided. |
easting | The easting provided to the API in the request. |
northing | The northing provided to the API in the request. |
latitude | The latitude of the converted coordinates. |
longitude | The longitude of the converted coordinates. |
Free to use for any purpose.
A credit and a link back to this page would be appreciated, but not required.
Successful JSON Response
Request: https://api.getthedata.com/bng2latlong/326897/673919 { "status":"ok", "easting":326897, "northing":673919, "latitude":55.95271, "longitude":-3.17227 }
JSON Error Response
Request: https://api.getthedata.com/bng2latlong/not-an-easting/not-a-northing { "status":"error", "error":"Both <easting> and <northing> must be provided, must be positive integers, and must be within range. Where provided, <format> must be \"xml\" or \"json\"." }
Successful XML Response
Request: https://api.getthedata.com/bng2latlong/326897/673919/xml <?xml version="1.0" ?> <result> <status>ok</status> <easting>326897</easting> <northing>673919</northing> <latitude>55.95271</latitude> <longitude>-3.17227</longitude> </result>
XML Error Response
Request: https://api.getthedata.com/bng2latlong/not-an-easting/not-a-northing/xml <?xml version="1.0" ?> <result> <status>error</status> <error> Both <easting> and <northing> must be provided, must be positive integers, and must be within range. Where provided, <format> must be "xml" or "json". </error> </result>
The coordinate conversion is done in PHP using Doug Wright's PHPCoord, which is itself based on Jonathan Stott's original PHPcoord. Thank you to Doug and Jonathan for doing the heavy lifting, and placing their work in the public domain.