In the last post, I covered a mildly painful way to convert the vector data (points, paths, and polygons) in Google Earth KML files to shapefile format, while keeping at least the name associated with the points and paths. Today, I’ll describe a simpler and faster two-step process, but one that unfortunately doesn’t keep the name or any of the other KML data associated with the original shapes.
This process works with any KML file, with any combination of points, paths, and polygons; unlike the previous approach, there’s no real benefit to saving points, paths, and polygons in separate files. Here’s a screenshot of the KML data I’ll be using in this example:
The first step is to convert the KML files into AutoCAD DXF format using KML2x website tool. This website actually converts KML files not just into DXF format, but also GPX, Surfer, and several text formats (CSV and tab-delimited text, although some editing would have to be done to make these textfiles importable into a spreadsheet). Here’s a screenshot of the website with a KML file loaded in:
The text that appears in the box below is the actual KML file content. You might have noticed that under File Format, SHP-ESRI is listed as an option. It’s currently not enabled, but hopefully at some point in the future it will be, and you’ll be able to do a direct conversion. But for now, you have to follow the DXF route, because there’s a way to convert DXF files to shapefiles.
With DXF selected as the file format for export, and the desired coordinate system (UTM or geographic) specified, you can select point, path, and/or polygon as the desired data types to export. For subsequent steps, I’ve found that it works best to export the data types into their own separate DXF files, rather than all together. Click on Export at the top, and a new browser window will open with the DXF content in a text box:
Select the text in the box, copy it into your favorite text editor, then save it as a DXF file (*.DXF).
Next comes the conversion to shapefiles. For this, you can use a DXF to shape converter available either as a plug-in for MapWindow GIS, or as a stand-alone application; the process below and the screenshot are for the MapWindow plug-in version. Select “Import AutoCAD DXF File” from the “Importers” menu (if it’s not visible, check to make sure it’s been enabled in the “Plug-ins” menu, and installed properly in the plugins directory). The following window will come up:
Specify the input file, the name and location of the shapefile to be created, and select the filetype that matches the input file. You can create and save a log file in the process by checking the appropriate box, and you can also add the newly-created shapefile to the current view in MapWindow by checking the box at the bottom. Click on Convert, and the shapefile should be created. Here’s a screenshot from MapWindow of the three shapefiles (point, line and polygon) exported from the original KML file into DXF format, then converted into shapefile format:
Don’t forget that positions in Google Earth can be displaced from their true positions by a significant amount.