Monday, November 5, 2012

Creating and Uploading KML files to a Blog

Nothing New, But a Useful Tool for Geoscientists


Embedding a Google Earth with a custom KML file is not anything new that you can do, but I think it is a useful tool for Geoscientists. I also found some complications at the Google tutorial (basically hard to find links) that I am trying to iron out with my descriptions below. And in addition to an attempt to make life easier for others I am also trying out to see if everything works the way it was presented on the Google tutorial. I found that uploading documents to Google Docs doesn't work quite right with Google Drive (which surprises me, I probably made a mistake somewhere).

Recently I have been playing with the Google Earth tools for embedding Geophysical data in websites. It is actually a fairly simple processes, so I will go through the steps and embed a KML document in this page.
  1. You will need some kind of webspace or a blog that will allow you to edit HTML and add some scripting code.
  2. And you will need to create KML data and check that it looks right in Google Earth.
  3. The KML file needs to get online.
Once you have those in place you will be ready to walk through the tutorial at this site:
http://www.google.com/earth/outreach/tutorials/kmlembed.html

Since uploading the file took a little work I will outline what I have done to put my data online and how I have created the embedded Google Earth widget below. Basically I just followed the steps in the link I gave above.


Uploading KML File A Google Web Page or Google Drive (formerly Google Docs)


In Google Drive I created a folder called kml, and I uploaded my KML file for a walk I sometimes take on campus at Seoul National University (SNU).
This site might help with uploading your KML file: http://support.google.com/earth/bin/answer.py?hl=en&answer=173934
  1. Upload File
  2. Set Visibility to Public
  3. Get a link to the file. 
NOTE: Google Drive didn't work correctly for me, So I redid the steps uploading my data to a Google Site. If you got Google Drive to work with your KML file please let me know what you did so I can double check to find where I made a mistake.

I uploaded my data to a Google Site by creating a "New Page" and for the kind of page I selected "File Cabinet". Then I uploaded my KML file and copied the download location from the download link created.


Using the Embed KML Gadget


The KML gadget creator is located here: http://www.gmodules.com/ig/creator?synd=open&url=http://dl.google.com/developers/maps/embedkmlgadget.xml

In the Creator paste the URL for your KML file into the correct box.
You can adjust the following parameters:
  • Adjust Title for the Gadget
  • Set Height & Width (Bigger viewers will load more slowly, I went with the default 500x400px)
  • Set Border Color
  • And Control what data is loaded with your KML file.
When your done picking your settings, then hit the button to "Get the Code", and the code will appear below on the page.

Embedding the code in your webpage/blog


You will have to have a way to add html, and you can add the scripted code in your HTML where you want your embedded map!

You may need to download the Google Earth Plugin for your browser, but when you do you should see the map I created for my occasional after-work walk.

I hope this guide is useful to helping you to integrate your Google Earth KML file into your web page!