I would like to find an API whereby I can send it (UK) lat and long pairs and it will return a UK county if one exists for that pair.

Ideally I will send it {50.3755,4.1427} and it will return {Devon}.

I understand that this isn't a coding or directly technical question but it seemed like the best place to ask with the breadth of experience.

Has anyone had this requirement before?

closed as unclear what you're asking by whyzar, mgri, John Powell, nmtoken, Dan C Jun 20 '17 at 20:16

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Thinking the OS SPARQL Linked Data API might be of use here (data.ordnancesurvey.co.uk) did you try already? – nmtoken Jun 20 '17 at 12:45
  • Nominatim API (OpenStreetMap) your lat/lng goes to the api nominatim.openstreetmap.org/… you get a response in xml. – Mapperz Jun 20 '17 at 14:59
  • Unfortunately that returned Plymouth as the county of Plymouth. What do you think could cause that? That lat,long is a minimum of 1 mile from the county boundary if that's an issue. – Banners Jun 20 '17 at 15:02
  • I haven't tried the OS API - do you know if it'll take a lat long? I couldn't see anything in the documentation. – Banners Jun 20 '17 at 15:05
  • Which OS API? It is fairly straighforward to convert OSGB to lat/long. – John Powell Jun 20 '17 at 15:18

I don't know of an API or existing service but it would be trivially easy to build one with GeoServer and OS BoundaryLine data bearing in mind that much of Britain isn't in a county.

Just load the data into the GeoServer.

enter image description here

Then make a GetFeature request against it using something like:


And you could even change the return type to json and get:

{"type":"FeatureCollection","totalFeatures":1,"features":[{"type":"Feature","id":"county_region.6","geometry":{"type":"MultiPolygon","coordinates":...},{"geometry_name":"the_geom","properties":{"NAME":"East Sussex County","AREA_CODE":"CTY","DESCRIPTIO":"County","FILE_NAME":"EAST_SUSSEX_COUNTY","NUMBER":16,"NUMBER0":502,"POLYGON_ID":122242,"UNIT_ID":2625,"CODE":"E10000011","HECTARES":172516.861,"AREA":1247.727,"TYPE_CODE":"AA","DESCRIPT0":"CIVIL ADMINISTRATION AREA","TYPE_COD0":"","DESCRIPT1":""}}],"crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG::27700"}}} 
  • I'd be really happy to get to the 83 metro/non-metro counties. Thanks for your guidance, I'll look into this. – Banners Jun 20 '17 at 13:14
  • I think they are a different layer in boundaryline though still just GB not UK – Ian Turton Jun 20 '17 at 13:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.