Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Country code from a latitude longitude position (without using geocoding services)

How can i get the country code from a latitude longitude position?

I know that there are many geocoding services available, but they don't meed my requirement because my application gets blocked a few hours after it goes live (many geocoding requests).

Most geocoding services also offer commercial services, but they are not yet a option because the project is in it starting blocks.

I did a bit of research and think i found a way to do it: Get a shape file (or other data file) that contains the borders of all countries (in polygons). Next just look in which polygon the lat/lng position is. Finally read the meta data from the specific polygon.

Does anyone know where i can get a shape file (or other format) that includes polygons (or just lines) that show the borders of all countries in the world?

Or is there maybe a easier way to solve this problem?

like image 487
T. Akhayo Avatar asked Oct 24 '22 18:10

T. Akhayo


1 Answers

Given the number of countries (polygons) in the world, you may want to subdivide the set of country polygons to do a rough filter first (e.g., if the point is in the western and northern hemispheres, only need to check North American, Central American, and Carribean countries. That may give you a speed improvement.

Also, keep in mind that many countries consist of multiple polygons, just keep that in mind as you code.

I haven't used any of these sources for country boundary data, but checkout: http://geocommons.com/overlays/33578 and http://geospatial.edublogs.org/2010/06/29/world-country-boundary-files/

like image 155
ViennaMike Avatar answered Oct 27 '22 11:10

ViennaMike