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:

sample KML file for conversion to shapefile

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

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:

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:

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:

KML file converted to shapefile

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 .

Other posts in the KML To Shapefile Conversion series

  1. Converting Google Earth KML Files To Shapefile Format
  2. Another Way To Convert Google Earth KML Files To Shapefiles
  3. The Last Word (For Now) On Converting Google Earth KML Files To Shapefiles


Subscribe to this blog's RSS feed

1 Response 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

Leave a Reply


Be sure to enter the "reCAPTCHA" below before submitting your comment.