Need to find latitude and longitude of postcodes and store into my database [closed]

好久不见. 提交于 2019-12-19 04:06:17

问题


I’ve got a database full of UK Postcodes, now I’d like to be able to store the latitude and longitude of these specific postcodes along with the record with the database. Is there any way that I can obtain this data free without violating any T&C's?

I know I could do this using Google maps API for each postcode, but I have way over 20,000 postcodes in this database and to get the lat and lng for each of these postcodes each time is not an option really.

Thanks in advance, M


回答1:


Postcode location data is available free now. See this answer:

  • https://stackoverflow.com/a/2625123/587803

https://www.ordnancesurvey.co.uk/opendatadownload/products.html

The one you want is "Code-Point open".




回答2:


Here it is. Dumped SQL table full of Postcodes, LAT/LON, X/Y coordinates :)

Download zip (UK-Postcodes.zip) and for more info read [same-website]/guides/article.php?article=64 :)

I haven't tested it, but it should be working, lad :)

Happy coding ^^




回答3:


Maybe Nominatim should do the trick. The only problem is that it might not be up to date.




回答4:


Geonames.org offers a free downloadable database. You could try Bing API or other commercial offerings but they have rather restrictive T&C in how many queries you can make within a time period, how you can use it (needs a lawyer to interpret their nuances).

I found Geonames.org to be more than sufficient for my needs.




回答5:


For postcode database, unfortunately I cannot help you.

But for Google... You know, you don't have to do this for EVERY postcode EACH time. You can cache the values in your database and do it only once for each new postcode. Although this will take some time, it's possible.

Yeah, it still sucks. But better than nothing.




回答6:


http://www.freethepostcode.org/ provides information you may find useful.




回答7:


I've only seen this done from a local database with commercial software, possibly because of the licensing restrictions the Royal Mail put on their postcode data.

There are APIs with reasonably high rate limits that can geocode UK postcodes, though. Yahoo's geocoding API is restricted to 5,000 hits a day, but that means you could have your entire database done in four days, store the lat/lon in the database, and just use it to add new addresses as they come in, say.

Also -- how accurate do you need the information? If you just need a rough location, you could geocode to the Outbound (e.g. "BS1"); I've seen user-sourced databases of at least arguable legality around the net for that.



来源:https://stackoverflow.com/questions/2644035/need-to-find-latitude-and-longitude-of-postcodes-and-store-into-my-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!