Using Google for Mapping Your Data

(creating KML files for either Google Earth or Google Maps)

 

Back to the   GIS Tutorials & Help Page...                         Back to the   SAL Home Page...

 

Notes on .KML and .KMZ files

ArcGIS to KML (converting GIS data to KML files)

Converting KML files to Shapefiles (importing KML files)

Converting GPS data to KML

Viewing .KML and .KMZ files in Google EARTH

Viewing .KML and .KMZ files in Google MAPS

Viewing .KML and .KMZ files Using Google's My Maps

    How to export a My Maps map to kml (& Convert it to a shapefile)

Other Options for .KML and .KMZ Files

 

See also: Using a spreadsheet to create a kml file

 

While by no means a full GIS package, Google Earth/Maps offer increasing possibilities for displaying not only their data, but yours by creating and using a .KML file. The most basic method of creating a KML file is to open Google Earth and create markers that you can save to a .KML file. In addition, you can also bring in existing data to create a .KML file. Below are some rough notes on methods of getting your GPS or GIS data into a KML file that can be used in either Google Earth or Google Maps.

 

See also Using the Image Overlay Tool in Google Earth (to add your own GIS imagery files)

 

~ ~ ~ ~ ~

 

Notes on .KML and .KMZ files

 

The default file for spatial data in Google Earth is a .KML file. A .KML file is a "flat" file (text based) composed of Tags similar to .XML or .HTML. KML files can also be converted to a .KMZ file. The differences between .KML and .KMZ is that a .KMZ has been compressed ('zipped' up) using an application such as WinZip. The .ZIP file is then renamed as a .KMZ (this renaming was done so that your computer would automatically recognize it as a file that can be opened in Google Earth and not WinZip).

To create a .KMZ yourself:

    Create your .KML (from Google Earth or as detailed on this page)

    Use WinZip to compress the file

    Rename the file extension from .ZIP to .KMZ

 

    Try double clicking on the .KMZ file you just created

    This should automatically open in Google Earth

 

You can also open a .KML file in Google Earth and save it as a .KMZ file.

 

There are a growing number of .KML files that are now available on the web. One method of searching for such files is to use Google search and add the following text string:

    filetype:kmz (or filetype:kmz)

So if you wanted to search for files for Bellingham you could enter:

    bellingham filetype:kml or bellingham filetype:kmz

 

Suggestion: search for a KML file or two, download (save) these and open them (in a text editor) to get a sense of what is in a KML file and how they work...

 

~ ~ ~ ~ ~

 

ArcGIS to KML (converting GIS data to KML files)

 

ArcGIS 9.3 has a Layer to KML tool (ArcToolbox / Conversion Tools / To KML / Layer to KML) and a Map to KML tool (ArcToolbox / Conversion Tools / To KML / Map to KML). Both of these can be used to export GIS data (shapefiles, etc.) to a KML file for posting on the web, etc.

 

ArcGIS 9.2 also has a Layer to KML tool IF you have the 3D Analyst extension (ArcToolbox / 3D Analyst Tools / To KML / Layer to KML) - note that you must turn the 3D Analyst extension on (from the Tools / Extensions menu)

 

In the SAL (AH-16) we have also added an extension that will allow you to export a shapefile (points, lines or polygons) to a KML file. Included in this process are limited options for also setting symbology (colors, symbols, transparency) or annotation (labels) for the exported features. This extension can be freely downloaded from ESRI's ArcScripts webpage.

 

To use this extension:

 

    Open ArcMap

    Add the data you wish to export

    From the Tools menu choose Extensions

    Check the box  Export to KML to activate the extension

    From the View menu choose Toolbars

    Check the box beside Export to KML to turn the toolbar on

    Click on the single icon of the Export to KML toolbar

    Follow the options/instructions

    See notes below on using KML files...

   

~ ~ ~ ~ ~

 

Converting GPS data to KML

 

If you have GPS data, you could import it into ArcGIS (see GPS data in ArcGIS and XY Data in ArcGIS) and then use the Export to KML extension (see notes above). Alternatively, you can go directly from a table of GPS data to a KML file using on-line conversions programs.

 

GPS Visualizer is a web application that will convert lat-long coordinates,  or a table of lat-long coordinates, to a kml or kmz file (for free):

 

http://www.gpsvisualizer.com/map?form=googleearth&googleearth_docname=gpstest&googleearth_zip=0

  • Tables can be ".csv" (comma delimited) or tab delimited

  • Header (first) row must have field headings

  • Coordinates must be Lat-Long (not UTM or State Plane)

  • Note that if all you have are just the X-Y coordinates (no other attribute information like a name or ID number) the program will assume that your data is for a track (a linear feature) and connects the dots. To avoid creating tracks and force it to create just point features, add a new field (such as Name or ID) to your table.

This will produce a .KML (or a .KMZ) file that you can view in Google Earth or download (use Save Link As or Click link and select Save to Disk instead of viewing). You can rename the .KML file once it has been downloaded if you need to.

 

~ ~ ~ ~ ~

 

Viewing .KML and .KMZ files in Google EARTH

 

All you need to do is click on the file to open it in Google Earth (assuming you have Google Earth installed).

 

You can also post your file to a web page as a url - which will then open on the user's computer (assuming they have Google Earth installed). NOTE: this only works from some web servers (WWU's U:/ drive myweb folders now work). Alternatively, users can download your .KML or .KMZ file to their hard drive and double click on it to open the local copy.

 

So if you have a KML file of points in the Bearing Sea:

        http://staff.wwu.edu/stefan/G_test/B_Sea.kml

or the Bellingham Schools:

        http://staff.wwu.edu/stefan/G_test/Bham_Schools.kml

 

Anyone can click on these files and open them in Google Earth.

   

~ ~ ~ ~ ~

 

Viewing .KML and .KMZ files in Google MAPS

 

Even though .KML files are intended for Google Earth, they can also be used in Google Maps. It seems that to do this the .KML file has to be on the web (you can simply put it in your U:/ drive myweb folder or post it elsewhere online). (So far I haven't found a way to use a .KML file on your hard drive in Google maps... if you do, let me know).

   

To open a KML file in Google Maps:

    Open Google Maps ( http://maps.google.com/ )

    In the Search box enter the url for your .KML file

        (e.g. http://staff.wwu.edu/stefan/G_test/B_Sea.kml

        or http://staff.wwu.edu/stefan/G_test/Bham_Schools.kml )

 

If you want a link on a web page to open in Google maps you need to add http://maps.google.com/?q= before the .KML address in your link, e.g.:

        http://maps.google.com/?q=http://staff.wwu.edu/stefan/G_test/B_Sea.kml

 

or     http://maps.google.com/?q=http://staff.wwu.edu/stefan/G_test/Bham_Schools.kml

 

TIP: If you want your Google Map to open with the Satellite background (instead of the default basemap) add "&t=k" (no quotes) at the end of the link:

 

       http://maps.google.com/?q=http://staff.wwu.edu/stefan/G_test/Bham_Schools.kml&t=k

 

 

 

OR Viewing .KML and .KMZ files Using Google's My Maps:

 

From Google Maps there is a tab for My Maps (a way to create, save and share Google Maps). If you create a new map you can import a KML file and save that out as a My Map. NOTE: You'll need to have a Google account to create, save and share your Google Maps.

 

Basic My Maps Functionality:

    Open Google Maps ( http://maps.google.com/ )

    Click on the My Maps tab (on the left hand side of the screen)

    Click on Create new map

    Sign in if you aren't already (you have to have a Google Account to play this game...)

        If you don't have a Google Account, use the Create an account now button to do so

    Give the new map a Title in the dialog section

    Click the Add a Placemark icon to add markers to your map

        You can then give your placemark a Title and/or Description

        Use Rich Text or Edit HTML to add images, hyperlinks, etc.

        You can also add Lines or Shapes (polygons)

        Existing placemarks can also be moved (relocated)

 

To Add a Placemark using Latitude-Longitude Coordinates:

    Open Google Maps

    In the Google Maps Search box, enter a set of Lat-Long coordinates

        e.g.: 48.738221, -122.486432

    Click Search Maps

        Google should zoom to your location and create a temporary placemark

        Click on your placemark and in the pop-up box click Save To My Maps

        Choose the Name of your Map to add the placemark to

        Click Save

 

To Import a KML file into your My Map:

    Create and begin editing your map (see above)

    Click on the Import link

    Browse to a KML file on your computer and Upload it...

    If you have the same file on the web (i.e., on your mywebs folder on your U:/ drive)

        you can enter the URL and click Upload from File

 

Linking to your My Map:

    You can get a URL link for your My Map by clicking on Link

    Copy and paste the URL or the HTML code into your web site

    You can now delete your version of the KML (as Google is now hosting their copy of it...)

 

Sharing your My Map:

    Click on Send

    Enter the To and From email addresses & click Send

 

 

You can also get coordinates from Google Maps by using the following script...

Getting Latitude-Longitude Coordinates from Google Maps:

    Go to Google Maps ( http://maps.google.com/ )

    Zoom / Pan to your desired location

    Zoom in as far as you can, with your location centered in the screen

    In the browser address bar, replace http://maps.google.com/ with the following line of text:

 

        javascript:void(prompt('',gApplication.getMap().getCenter()));

 

    A pop-up window should display your coordinates in latitude and longitude.

 

 

How to export a My Maps map to a kml file (and convert that to a shapefile)

 

    Google's My Maps can be used as a simple tool for creating and sharing spatial data (digitizing points, lines or polygons on line). This data is stored on Google's servers as a kml file. To get a copy of the data off of Google's servers (for incorporation into ArcGIS, etc.) you can export your own kml file:

 

    From your My Map click on Link

    Copy and paste the URL into your web browser (as a new url)

    To the end of the url add:

            &ouput=kml

    Click return/enter

        (This should output a kml file which you can open in Google Earth or save)

    Choose to Save File and browse to the folder of your choice

 

 To convert a KML file to a Shapefile

    If you have the current version of ArcGIS there is now a KML to Layer tool (Conversion Tools / From KML / KML to Layer). If you have an older version of ArcGIS or if the tool isn't working for you there are various other ways to convert a KML file to a shapefile:

ArcScripts has:

    KML 2 SHP Converter tool: http://arcscripts.esri.com/details.asp?dbid=14988

    Convert KML files to Shapefiles: http://arcscripts.esri.com/details.asp?dbid=15603

    KML Conversion: http://arcscripts.esri.com/details.asp?dbid=14980

    (or search ArcSripts for KML)

 

    The DNR GPS (formerly "DNR Garmin") program (which is installed in the SAL) (see http://www.dnr.state.mn.us/mis/gis/DNRGPS/DNRGPS.html ) can read a kml file (as well as a GPS file or a shapefile). Once you have loaded a file (KML or otherwise) you can export it out as a shapefile (or a text file or a KML file, etc.)

        (File / Load From / File: Type = Google Earth Format *.kml)

        Once loaded, the file can then be sent to a GPS unit or saved as a shapefile

 

Zonum Solutions has a online kml2shp tool: http://www.zonums.com/kml2shp.html

 

Or Search for kml shapefile conversion (or the like)...

 

~ ~ ~ ~ ~

 

Other Options for .KML and .KMZ Files (stuff I haven't tried yet)

 

There is an Excel macro that converts a list of coordinates into a .KML file (I haven't tried this yet but looks simple enough):

     http://bbs.keyhole.com/ubb/showflat.php?Number=613667

 

More notes on using KML on Google maps:

    http://googlemapsapi.blogspot.com/2006/11/kml-on-google-maps.html

 

KML Editor:

    http://www.ogleearth.com/2007/03/and_then_there_2.html

 

GPS Utility:

    http://www.gpsu.co.uk/download.html

 

Google Earth MyMaps/KML converter for Garmin GPS units

     http://www.takitwithme.com/ 

 

________________

 

NOTE: KML/KMZ files can be posted to U:/ drive websites..

             but cannot be posted to acadweb (the SAL site) - (not sure about the SANS server...)