Excel to KML converter

30,470 views
Skip to first unread message

simon_a

unread,
Sep 26, 2006, 4:32:16 PM9/26/06
to KML Discussions
Hello,

Attached is a simple MS Excel spreadsheet and macro. This tool will turn a list of names, co-ordinates, and descriptions into a KML file.

This should overcome some of the limitations of the default spreadsheet import - no limitation on number of placemarks (within reason), for example - but is still a very basic tool (you will need to enhance the VBA code to create more complex KML files).

There is an 'Instructions' tab but, basically, you simply populate the 'Data' worksheet and then run the 'generateKML' macro (hit [ALT] + F8 then 'Run').

I've included a few lines of sample data to play with...

[Edit: updated to change the default maximum number of placemarks from 5000 to 50000 (editable)]

See also Open GE from MS Excel, which allows you to click on a link in a spreadsheet to open that row's co-ordinate directly in GE:
http://bbs.keyhole.com/ubb/showthreaded.php/Cat/0/Number/774351

Disclaimer: This is provided 'as is' with no support or guarantees etc. Care should be taken opening any file including a macro - I've no reason to suspect that it contains a virus (I should hope not - that means my PC is infected!) but I still suggest scanning with an anti-virus tool just in case.



Simon.
613667-excel2kml02.zip

tekgergedan

unread,
Sep 27, 2006, 12:08:26 PM9/27/06
to KML Discussions
What about inserting a button?

I have another version of this. My mind differs from yours in managing scripts, thus I'd better not touch it. Is it a good idea to scan the rows until an empty row is found and include all the records upto it?

simon_a

unread,
Sep 27, 2006, 2:26:45 PM9/27/06
to KML Discussions
Hello,

Hey, I'm no programmer! In fact I find code efficiency and squeezing all your functionality into two-and-a-half lines of code quite boring. I stop when it does what I want - and that includes insertng a button

This was just a quick modification of something else I bodged together because people were finding the csv import restricting - specifically, this post:
http://bbs.keyhole.com/ubb/showthreaded.php/Cat/0/Number/592258

If what you import is simple, it should work just fine but if anyone wants to add more features/checking/functionality etc, be my guest!

I'm sure it's just becasue you're a perfectionist



Simon.

Valery35

unread,
Sep 28, 2006, 2:12:40 PM9/28/06
to KML Discussions
See interest link http://www.zonums.com/excel2GoogleEarth.html
Also very good site for many GE KML developers.

Thanks to Stefan http://www.ogleearth.com/2006/09/short_news_flic.html#comments

simon_a

unread,
Oct 16, 2006, 5:01:06 PM10/16/06
to KML Discussions
Hello,

Attached is a simple MS Excel spreadsheet and macro. This tool will turn a list of names, addresses, and descriptions into a KML file.

This is more or less the same tool as attached to the main post of this thread, except it allows you to import placemarks from address data rather than latitude/longitude co-ordinates. For example, placing a UK postcode into this field, such as 'SW1H 0BD' (without the quotes of course) will locate the centroid of that post code. Note that, when you open your KML file, it may take a while for GE to contact the servers and locate every placemark.

See the KML documentation for the <address> tag to find out what else to put into the Address field:
http://earth.google.com/kml/kml_tags_21.html#address

This tool should overcome some of the limitations of the default spreadsheet import - no limitation on number of placemarks (within reason), for example - but is still a very basic tool (you will need to enhance the VBA code to create more complex KML files).


There is an 'Instructions' tab but, basically, you simply populate the 'Data' worksheet and then run the 'generateKML' macro (hit [ALT] + F8 then 'Run').

645546-excel2kml-address.zip

RemKou

unread,
Oct 25, 2006, 5:59:31 AM10/25/06
to KML Discussions
Wow, this looks quite the thing i have been looking for. However, if I run your macro (the one in the opening post) the resulting KML makes GE move to a location somewhere in the pacific ocean??.... Whats wrong?

simon_a

unread,
Oct 25, 2006, 6:32:32 AM10/25/06
to KML Discussions
Hello,

What it outputs depends on what you've entered. Have you got you latitude and longitude the right way round?

Rather frustratingly, GE decides to change the order it which it wants latitude and longitude depending on what you're trying to do.

The other possibility is that it's getting confused by what's entered and defaulting to co-ordinates of '0,0', which is in the ocean just off the coast of Africa.

Also, the position that GE moves to is not necessarily anything to do with the co-ordinates of placemarks themselves. If you're using <LookAt> tags in your KML (the converter doesn't put these in by the way), it will fly to whatever these tell it to.

If you're still having problems, post the latitudes and longitudes and I'll have a look...



Cheers,

Simon.

RemKou

unread,
Oct 25, 2006, 7:25:43 AM10/25/06
to KML Discussions
Simon, thanks for your quick reply. I managed to solve the problem myself. The solution had to do with the national settings of windows. My windows is set to Dutch, therefore it automatically sets the decimal to , (comma) instead of . (decimal point). Next it turned out that the macro also automatically used , (comma) as the decimal. I then switched the country settings (in the configuration of windows) to US, and it works smoothly now.

Next thing ide like to figure out is how to add a choice of icon in your macro. Any suggestions?

simon_a

unread,
Oct 25, 2006, 7:41:49 AM10/25/06
to KML Discussions
Hello,

Ah, OK - I would never have thought about it using commas instead of decimal points.

I guess that this is excel 'helpfully' formatting the columns for you. As they are just text strings, you might be able to just change the format of the column - I can't test that easily as mine is set up in a British way. If you find out, let me know and I'll update the post.

Quote:

Next thing ide like to figure out is how to add a choice of icon in your macro. Any suggestions?




Any good at VBA scripting?

You've two options:
  • Open the KML file in GE as it is, right-click on the folder and select Properties > Style and change the Icon for the whole folder
  • Edit the macro and include the KML code for Icons in there

    I probably won't do that because I don't want this thing to become too complicated but it shouldn't be too difficult to work out - you'll need to add some code at the top for a <Style> to reference and a <styleUrl> in the code for each placemark. Have a look at the KML documention for more information:
    http://earth.google.com/kml/

    You could also set a style for a whole folder (described above) and then save that folder as KML and have a look at the code in a text editor - that willl show you the structure you need.



    Simon.

BusterDAN

unread,
Jan 9, 2007, 5:07:44 AM1/9/07
to KML Discussions
Excellent Simon....many thanks!

blueciccio

unread,
Jul 26, 2012, 7:55:20 AM7/26/12
to kml-support-g...@googlegroups.com
Hi
I'm trying to use this tool in Open Office, but nothing appens when I click [Alt] + F8
I've tried to exrcute macro from menu (see attachment), but not working...
Any help would be very appreciated!
Thanks,
Francesco.
sel-macro.jpg

Purnomo MHz

unread,
Jun 11, 2013, 12:14:32 AM6/11/13
to kml-support-g...@googlegroups.com
Hello,
I want to create line from point A (Lattitude A, Longitude B) to point B (Lattitude B, Longitude B) using MS Excel, can you help me?
Thanks you.
Purnomo

Mahmood Saleh

unread,
Jul 4, 2013, 2:01:31 PM7/4/13
to kml-support-g...@googlegroups.com
Hi everyone i have scenario like this and need detail answer as i am a bigner in this:1.                  It is expected that a crisis situation might happen while you are on duty. You will be instructed to provide a detailed printed list for the staff living within a certain distance from the center of the crisis in five to ten minutes. Knowing the location of the crisis and having the  Excel staff list with longitude and latitude coordinates and the KML layer converted from excel sheet,  provide the necessary description of each step needed to generate the required list.

G-Train

unread,
Jan 28, 2014, 5:01:19 AM1/28/14
to kml-support-g...@googlegroups.com
Did you ever figure out how to do this? I'm trying to do the exact same thing.

Tajammul Bangash

unread,
Mar 21, 2014, 2:00:18 PM3/21/14
to kml-support-g...@googlegroups.com
Hi,
can you add icon selection feature in your micro. for excel  to kml.
it will be helpful for me.
Thanks in Advance.
regards,
Tajammul
Reply all
Reply to author
Forward
0 new messages