blankblank blank




Converting Google Earth KML Files To Shapefile Format



Note: See this series of posts for info on converting shapefiles to KML format.

I haven’t really found a good way to transform KML files to shapefile format, and certainly not one that preserves most of the attribute information or data associated with the shapes in the KML file. But I’ve come up with a mildly painful, multi-step hack that will allow you to convert the point, path and polygon shapes to shapefile format, and which allows you to keep at least the object name associated with points and paths.

Step 1: If the KML files consists of points, lines and polygons, it will be helpful if you can save the points and lines in their own KML file, then do the same for the polygons by themselves.Step 2: Convert the KML file into GPX using GPS TrackMaker. Here’s an image of a simple KML file in Google Earth, with two points, lines, and polygons:

combined2

Here’s the same KML file opened up in GPS TrackMaker (I haven’t deleted the polygons yet):

gpstrackmakerkml

The name labels in GPS TrackMaker are those assigned to those shapes in Google Earth. I’ll now delete the polygons, and save the point and line data as a GPX file in GPS TrackMaker.

Step 3: Open the point and line GPX file in EasyGPS:

easygpspanl

The waypoints are marked on the screen with their original KML ID. Although the tracks don’t have their names on-screen, they still have their names associated with them; selecting them, right-clicking and choosing “Edit Track” will show that:

easygpsedit

If you want to keep that track name associated with the line when you create a shapefile, you will have to copy the text in the “Name” box into the “Label” box. With only a few tracks, this may be practical, but with a lot of tracks, you may find this more trouble than it’s worth.

Step 4: Save the point and line data in EasyGPS as a GPX file.

Step 5: Use EGPS2shp (described in a previous post) to convert the point and track data into separate point and line shapefiles (in geographic WGS84 coordinates). The “Label” data will be preserved, so that the shapes will have some ID associated with them.

That’s it for points and paths from Google Earth. The procedure is essentially the same for polygons, but in Step 2 GPS TrackMaker converts the polygon perimeters into tracks when it saves them as GPX files. And don’t bother copying the polygon name into the “Label” box in Step 3, since the process to create a polygon shapefile won’t save the polygon name.

So with polygons, at the end of Step 5 you’ll have a line shapefile describing the polygon perimeters, and not a polygon shapefile with actual polygons. But it’s possible to convert this line shapefile with polygon perimeters into an actual area shapefile with the full polygons themselves. Open the program DNRGarmin (discussed in earlier posts), go to File => Load From => File, and load the “polygon” line shapefile you just created into DNRGarmin. Then select File => Save To => File, select ArcView shapefile (unprojected) as the file type to save it as, enter a filename and click “Save”. A radio dialog will pop up, asking you to define the output shape, and you should select “Polygon” and click OK. The line shapefile with the polygon perimeter tracks will be converted into a polygon shapefile with each track converted into a separate polygon.

Here’s a screenshot from MapWindow GIS, showing the point, line and polygon shapefiles generated by the above process:

mapwindow

If you can’t separate the points, paths and polygons into separate KML files, you can still follow this basic process. The main difference will be that when you open the KML file in GPS TrackMaker, it will have the points, the paths, and the polygons all together. Delete the polygons in GPS TrackMaker, then save the points and tracks in a separate GPX file, and follow the process described above. Then open the original KML file in GPS TrackMaker, delete the points and tracks (leaving the polygon perimeters), save the polygons as a separate GPX file, and run through the process for polygons. You could also convert the entire KML file to GPX in GPS TrackMaker, and then manipulate the polygons in EasyGPS, but TrackMaker has better selection tools for use in deleting shapes.

Yeah, this isn’t a very convenient approach, and if you have a better free one that preserves any of the attribute data, I’d love to hear it. Failing that, it will have to do until somebody comes out with a full-blown KML to shapefile converter. You can always use a format converter program like the excellent Global Mapper, which can open KML data and export it in shapefile format, but at $279, it’s not cheap.

Tomorrow: an easier way to convert KML to shapefile format, but which doesn’t preserve any of the attribute data .


Looking for something else? Enter some keywords below, then click "Search".    




8 Responses to “Converting Google Earth KML Files To Shapefile Format”


  1. 1 Anonymous

    I`m just find a web with some kml utilities for free.
    http://www.geo-news.net

  2. 2 Rizah Murseli

    Good try!

  3. 3 Rizah Murseli

    Interesting!

  4. 4 Dan Foster

    Wow, that’s a convoluted way to convert KML to SHP. I’m the author of the EasyGPS freeware mentioned in steps three and four. I’ve written a detailed tutorial about using EasyGPS’ big brother, ExpertGPS Pro to convert KML and KMZ to SHP. It’s a two-step process – once you’ve got your coordinate systems defined, it’s just import KML, and export SHP. I realize this site is about free and open-source solutions, so I’m willing to work with anyone who can’t afford ExpertGPS Pro at it’s full price of $99. I’m also working on a standalone KML to SHP converter that will have many more options for preserving KML metadata (labels, descriptions, links to photos, etc). Drop me an email if you’re interested.

    http://blog.expertgps.com/blog/2009/03/how-to-convert-kmz-to-shp-a-step-by-step-tutorial/

  5. 5 Leszek Pawlowicz

    Well, this blog is all about doing it for free, regardless of how painful :). The process described for KML to shapefile definitely is convoluted, as is the one in the next post:

    https://freegeographytools.com/2007/another-way-to-convert-google-earth-kml-files-to-shapefiles

    However, a later post describes a free application that converts KML files directly to shapefiles:

    https://freegeographytools.com/2007/the-last-word-for-now-on-converting-google-earth-kml-files-to-shapefiles

    That application currently has a fatal bug, but the author has created an online KML to shapefile converter:

    https://freegeographytools.com/2009/online-kml-to-shapefile-converter

    There are many paid apps that will convert KML files to shapefiles; two more GPS-related ones Are GPS TrackMaker Pro:

    http://gpstm.com/gtmpro.php

    and GPS utility:

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

  6. 6 Max Nielsen-Pincus

    I also found an easier free way to convert from KML to SHP using GPS TrackMaker and Excel. Import your KML to GPS TrackMaker. Under the File menu select Convert Files. Select you KML file in the Origin file field and select the .txt option in the Target file field. You now have a .txt file that can be opened in Excel and that includes your coordinate system in the first row and coordinates as fields along with any attribute data originally associated with you file. You can then convert the file in Excel to a dBase, open the dBase in ArcGIS, and then using the Add XY Data under the Tools menu convert the file to a shapefile in ArcGIS.

    When I did this I found that there was some manual arranging of data in Excel I had to do to have everything I wanted formatted the way I wanted it. Depending on the complexity of the original KML attributes this may prove too time consuming for you, but it’s worth a try.

  7. 7 Joe

    I’ve tried both the ExpertGPS Pro and online version from Zonum.

    ExpertGPS crashes everytime I try converting a large kml with many paths (+1k), and Zonum created a shp that is totally useless. Actually, I’m not sure exactly what it created.

    I’ll try the excel approach…

  8. 8 fevisis

    We have a converter to convert Google Earth’s KML file to Shape file(kml2shp). This converter can convert any type of KML to the Shape file format as per the standards. With this converter, you get the advantage of having your own shape file for any area of the world thus relieving your need to search or purchase the Shape file . This converter proves to be a User Friendly one as its GUI is so simple that you don’t need to specify anything for conversion.

    You all get this for a very minimal one time cost. If you like to have your own converter for generating shape file, reach us at dev.fevisis@gmail.com

    Regards
    fevisis dev team
    Website : http://www.fevisis.com – Coming Soon…………..
    Blog : http://fevisis.blogspot.com
    http://fevisis.wordpress.com
    mail : dev.fevisis@gmail.com

Comments are currently closed; feel free to contact me with questions/issues.