Converting KML files to shapefiles in ArcGIS with the KML to SHP tool
Author: Jason Parent (jason.parent@uconn.edu)
Date: May 3, 2008
Modified by: Robert McCann
Modified on: June 6, 2008
Modified by: Charles Morton
Modified on: August 24, 2009
The purpose of the Convert KML to SHP tool is to convert Google Earth kml files to shapefiles.
The output shapefile will contain feature names, descriptions, and Google Earth folder as
attributes. The coordinate system of the output shapefile is in geographic coordinates (WGS84).
The kml file may contain any number of points, lines, and polygons. The script will create a
shapefile for the feature type of interest. If the kml file contains more than one type of feature,
you will need to run the script once for each feature type that is to be converted to a shapefile.
When digitizing in Google Earth, it is recommended that you store all features intended for a
given shapefile in a single folder. You can do this by using the following procedure:
• Create a folder in the google Table of Contents by 1) right-clicking on My Places, 2)
click Add, and 3) click Folder.
• Add features to the folder by clicking on the folder so that it is highlighted. Then proceed
to create polygons, lines, or points.
• When finished creating features, save the entire folder as a kml file by 1) right-clicking
on the folder, 2) select "Save As", and 3) change type to kml. Individual features may
also be saved as kml files.
About the script…
The KML to SHP tool is a python (version 2.4) script that has been set up to work from within
the ArcToolbox of ArcGIS version 9.2 or later. The script will not work with ArcGIS 9.1 since it
does not use an equivalent version of python. The script is designed to read kml files generated
by Google Earth version 4.2 (Nov 13 2007) or later and may not read kml files generated by
earlier versions. The script cannot convert kml files generated in Google Maps. Before you can
run the script in ArcGIS, you will need to load the script’s toolbox into ArcToolbox.
Loading the KML_to_SHP toolbox into ArcToolbox:
The download from the ESRI ArcScripts site contains the file KML_to_SHP.tbx – this file is the
toolbox which you will need to load into ArcToolbox (unless you are using ArcGIS v9.2). If you
are using ArcGIS 9.2, you will need to load the KML_to_SHP_9_2.tbx toolbox. The
kml_to_shp.py is the script file which must always be kept in the same location as the .tbx file so
that the toolbox can find the script.
评论25