We have been working on some code to determine whether or not a placemark lies inside or outside a polygon. We thought a nice use for that code would be to determine what country a placemark is in. For this we required the outlines of countries in KML format. We discovered ThematicMapping.org has a map of country outlines provided here. The Thematic Mapping API is a brilliant JavaScript API to help you create KML based thematic maps. See here for some of our previous posts about it.
The world country map is provided in what is known as the shapefile format. It is a popular format developed and maintained by Esri for use in GIS products. Google Earth Pro, it turns out, has built-in support for importing shape files. Simply go to File->Import then select “Esri Shape (*.shp)” from the file types list. Google Earth Pro then asks you if you want to apply a style template to the features you just ingested. We found that if we chose not to do so then all the shapes were named ‘[no-name]’. So, instead we chose to apply a style template which gives us the option to name the polygons from a field in a table of data included in the shapefile. One of the columns contains the country names, so we used that. There is also an option to colour the shapes based on a field in the data, all a single colour or random colours. We chose random colours. You can also set the icons and heights from fields in the data, but neither was appropriate in this case.
GEB reader Clare has noted that the map is a bit out of date with Sudan shown as a single country.
Once imported, if you click on one of the countries it shows a popup with some basic data about each country, such as name, area and population figures from 2005, which were contained in the shapefile. It is also now possible to save the dataset as a KML file. The resulting file is a little large, at 10.7MB, but compresses down to less than a third of that size when saved in the compressed KMZ format.
The original shapefile is shared under the Creative Commons ShareAlike licence, so you are free to use it on condition you give proper attribution to the original source. So, if you want some country outlines for use in Google Earth here is the KMZ version.
We have also created this version with all the extra country information removed, as well as changing the styles so as to only show country outlines.
About Timothy Whitehead
Timothy has been using Google Earth since 2004 when it was still called Keyhole before it was renamed Google Earth in 2005 and has been a huge fan ever since. He is a programmer working for Red Wing Aerobatx and lives in Cape Town, South Africa.
Hi Timothy. Your Outlines file is missing Pakistan, can you repost again with this addition please? Thanks for the great files 🙂