Toby logo

Country Borders

Download the latitude and longitude co-ordinates of each point on each country's border in countryborders.txt.

Version 2 is available here. it has not yet been documented, although the format is the same as version one.

About the file

  • The file is comma delimited and consists of four columns: "locationNum", "pointNum", "Longitude" and "Latitude".
    • The "locationNum" column shows which location a particular record belongs to. For each 'location', there are several data points, which, when joined together, will make a polygon showing the shape of the location it describes. Any one country can have a number of 'locations' - if two parts of the country are not connected (i.e. you cannot walk between them without crossing another country or the sea) then they will be registered as separate locations. This means that if a country is made up of several islands, then each island will be listed as a separate location.
    • Each record is given an individual "pointNum". This could act as the primary key.
    • "Longitude" is a decimal number showing how many degrees a point is from the Greenwich Meridian. This number could be between -180º and 180º. A positive number is used for locations to the East, and a negative number for locations to the West. The units are not shown.
    • "Latitude" is a decimal number showing how many degrees a point is from the equator. This number could be between -90º and 90º. A positive number is used for locations to the North and a negative number for locations to the South. The units are not shown.
  • The file is approx. 2MB and 95 000 long so Excel probably won't handle it. I recommend that you import it into a database program, such as Access.

Sample from the top of the file

How I made it

Remember that PowerPoint presentation that Google accidentally released? On slide 68 you may notice there's a world map. What's more, it's displayed as a series of freeform shapes, one for each country, that have been grouped together. What I did was I used VBA to extract the x and y co-ordinates of each point on the countries' borders, saved this data to a file then imported it into Access (it was too big for Excel).

I discovered that the map was in Mercator projection, and I found an equation to convert the x and y co-ordinates on the map to latitude and longitude. However, this equation would only work when the map I had was a certain size, to make the trigonometry work properly. Therefore, I had to first of all scale the map down to that size. To work out the equation needed to do that, I found the x and y co-ordinates on my map for a particular point (e.g. the South-West corner of Egypt's border) and then found out the real latitude and longitude for that point on the Internet. I then applied the formula to work out what x and y should be from the latitude and longitude. I repeated this with three other locations.

Once I had found four locations, I had to work out the relationship between my x and y co-ordinates, and what the co-ordinates should be. I found this using Excel's trend line tool, which displayed the equation on the graph. I applied this equation to the x co-ordinates, and another, similar equation to the y co-ordinates in the database.

I was then able to apply the main equation to convert from Mercator projection to latitude/longitude. Unfortunately, Access's range of functions was not as wide as Excel's so I often found myself hard-coding in values like pi. The equation was inserted into a query that output the latitude and longitude co-ordinates, which were then exported as a comma delimited text file.

Limitations

  • The country names are not shown. I hope to provide country names in a future release.
  • Currently, the file is only available in comma-delimited format. If you would like it in any other format, please contact me.
  • Parts of Greenland, the islands North of Canada and the Eastern tip of Russia have been chopped off. This is due to a limitation in the source data.
  • Antarctica is not shown, for the same reason mentioned above.
  • I have not thoroughly checked the data for accuracy, and there may be a few errors such as a location being in the wrong place or Germany appearing twice. Therefore, please don't rely on it for anything important.

Written by Toby. This work is licensed under a Creative Commons License. Privacy