Classifying placemarks by region

As we mentioned in yesterday’s post we have been working on a bit of code to determine whether or not a placemark lies inside a polygon. We believe we have got it working and thought it might be useful for people who want to classify placemarks by region. So, we have created the JavaScript-based tool below.

To use it, simply upload a set of placemarks and polygons and it will check what polygons the placemarks are in and put them all in folders named after the polygons and give you back a KML file with all the placemarks nicely categorised. As an example, we found this map of nuclear power plants on the Google Maps Gallery. We opened it in Google Earth to get the KML version, then used both it and the country borders we showed you yesterday to classify all the nuclear power stations by country.

It accepts multiple files so you can have your placemarks in one file and regions in another. It can be quite slow for large datasets. The above datasets took about 3 minutes on a fast computer.
[ Update: We have fixed a few bugs and added some optimizations which has improved the performance significantly.]

Include empty regions

As usual we have not yet tested it thoroughly and make no guarantees that it will work perfectly. The country outlines are not very high resolution so placemarks near borders may be incorrectly classified. Let us know about any bugs you find or enhancements you would like to see, in the comments below.

Once the placemarks are classified it is easy to select only one folder.

We were also able to use it to make an approximate list of the number of nuclear power stations per country. Note that the list includes both active and inactive power stations and lists individual reactors not sites. For example Pickering in Canada has 8 reactors. We also do not know how old the list is.

The biggest problem is that nuclear reactors are often near coastlines and as mentioned above, the country outlines are not very high resolution and many of the nuclear reactors are outside the country borders. So, of the 766 reactors in the original file, only 578 were successfully classified.

Country # of reactors
Armenia 2
Argentina 5
Australia 1
Bulgaria 5
Canada 24
China 22
Cuba 1
Czech Republic 9
Finland 2
France 71
Germany 32
Hungary 5
India 22
Iran (Islamic Republic of) 3
Israel 1
Italy 3
Iraq 1
Japan 45
Korea, Republic of 8
Lithuania 1
Slovakia 6
Mexico 1
Belgium 9
Netherlands 1
Romania 3
Russia 60
Slovenia 2
Spain 16
Sweden 9
Switzerland 11
Ukraine 22
United States 168
Taiwan 7

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.

PLEASE NOTE: Google Earth Blog is no longer writing regular posts. As a result, we are not accepting new comments or questions about Google Earth. If you have a question, use the official Google Earth and Maps Forums or the Google Earth Community Forums.


  1. Hi Timothy! Your app for classifying placemarks by region is an amazing idea, and I really appreciate the contribution to the community. If I am starting with a list of places delineated by street address within a CSV file, what must I do to encode those places in a KML file that I can upload along with polygon KML files into your app?

    Many Thanks,


  2. William Tuppeny says

    Strangely enough, I am trying to use your tool to evaluate 2 south african data sets – caltex station locations by lat long and magisterial districts which I loaded from some .shp files. I have saved each set as KML’s and then import these to your tool. when I do this the kml file generated is very small when compared to input files and practically blank. I then used a KML merging tool to merge the 2 kml’s into one KML and ran that through your file. The sorted kml file cannot be opened – GEPRO gives parsing error line 1 77478 not well formed invalid token…. Any hints or work arounds?

  3. Absolutely great! Love it!

    What could be better: if the text-file was structured (to open in a text editor).

  4. Hello Tim, thank you for the great code which worked perfectly for me in the last few months, today for one of my files after I sorted the placemarks I got a parse error [not well-formed (invalid token)], if you don’t mind, what is the probable cause for this error?

    • Timothy Whitehead says

      I would need to see the KML file to identify the issue. If you are able to email it to me I will have a look. My KML parser is not yet perfect so it could be an issue with my code, or it could be a fault in the KML file.

  5. Hey Timothy! This was super useful. I don’t know why it was so hard to find an app or site that would do this, but thanks for sharing it out!

    I’m a programmer, and I actually had a dataset that didn’t quite work, so I downloaded your javascript and tweaked it to work. 1st, I wanted all points to fall into only one region. Some of my polygons (accidentally) overlapped, and I wanted to make sure that if that happened, the points would still just end up in one or the other. 2nd, some of my points were using “multigeometry” (they had a point and a square around them), so I had to tweak the script a little to work with that. 3rd, I wanted points that fell outside of any region to get categorized into a “No Region” folder.

    But other than that, it works great! I hope you don’t mind me “branching” off yours 😉 It’s just for personal use.

  6. Sir

    my requirement is i am having map with survey number, i want to update my house lat & long and want to know which survey number my house falls.

    pl tell me the process.

    thanks & regards

PLEASE NOTE: Google Earth Blog is no longer writing regular posts. As a result, we are not accepting new comments or questions about Google Earth. If you have a question, use the official Google Earth and Maps Forums or the Google Earth Community Forums.