Guides ·

How to convert KML to shapefile

A KML from Google Earth or My Maps is one file that can hold pins, paths and areas together. A shapefile is the opposite: a small set of files that holds one kind of shape. This guide explains what a shapefile is made of, what changes when a KML becomes one, and how to convert it in QGIS or your browser.

Drop your KML or KMZ into the free unmake KML to SHP converter and download a checked shapefile zip.Try it on your own file
The unmake KML to SHP converter with smiley-uyuni.kml on the map and the result smiley-uyuni.zip, 2.9 KB: 1 document description not carried over, then 4 features, all 90 coordinates and 16 of 16 attribute values checked
smiley-uyuni.kml in the KML to SHP converter: what could not be carried, then the read-back check. Demo file made by unmake (not a real route); map © OpenStreetMap contributors.

What a shapefile is made of

A shapefile is not one file. It is a group of files with the same name, side by side in one folder. The .shp file holds the shapes: the coordinates of every point, line or polygon. The .shx file is an index, so a program can jump straight to shape number 500. The .dbf file is the attribute table, one row per shape, in the old dBASE format.

Those three are required. Two more are optional but nearly always wanted: the .prj file says which coordinate system the numbers are in, and the .cpg file names the text encoding, such as UTF-8, so accents and other alphabets survive. Without a .prj, your GIS has to guess where on Earth the shapes belong.

So a shapefile travels as a set. Zip the whole set before you email or upload it; a lone .shp is not usable.

A shapefile is several files sharing one name: .shp shapes, .shx index, .dbf attribute table (required), .prj coordinate system and .cpg text encoding (optional)
One shapefile, five files with the same name. The .shp, .shx and .dbf are required; the .prj and .cpg are optional but nearly always wanted.

Why one KML can become several shapefiles

Esri's rule is that a shapefile stores features of one geometry type. A KML has no such rule: a single file can mix pins (points), paths (lines) and areas (polygons).

So a KML with all three becomes up to three shapefiles, one per kind. The unmake converter names them with _points, _lines and _polygons at the end. Load all of them in your GIS to see the whole map again.

One KML with lines and points becomes two shapefiles, _lines and _points; the field name feature_kind is cut to feature_ki, 10 characters
The smiley's paths and points go into two shapefiles, and field names are cut to 10 characters.

What happens to names, descriptions and data

Each KML placemark has a name, often a description, and sometimes extra fields stored as ExtendedData. In a shapefile they all become columns of the .dbf table.

The .dbf has a strict limit: a field name can be at most 10 characters. So description becomes descriptio, and a field called feature_kind becomes feature_ki. If two field names only differ after the tenth character, rename them before converting; otherwise the converter renames one for you, and you lose track of which is which.

Plain KML data also has no types: every value is text. In our test, a number like 10 arrived as a text column. Change it to a number in your GIS before you sum it or colour shapes by it.

The attribute table of smiley-uyuni.kml in the converter: 4 features with the columns name, description, feature_kind and diameter_km
The KML's own field names before conversion: feature_kind and diameter_km become feature_ki and diameter_k in the shapefile. Demo file made by unmake.

Coordinate system and heights

KML coordinates are always longitude and latitude on WGS 84, the system GPS uses. The shapefile keeps WGS 84 and says so in its .prj file. If your project uses a local grid, such as a UTM zone, reproject the shapefile in your GIS afterwards.

Heights can come along too: if the KML has a third value in its coordinates, the shapefile can keep it as a Z value for each point.

How to do it in QGIS

Drag the KML into QGIS. If it mixes geometry types, export one type at a time. Use Select Features by Expression with geometry_type($geometry) = 'Point', then right-click the layer and choose Export, Save Selected Features As. Pick ESRI Shapefile as the format and a file name ending in _points.

Repeat with 'Line' and 'Polygon'. The same dialog has a CRS setting, so you can reproject in the same step.

How to do it in the browser

The unmake KML to SHP converter does the sorting for you. Drop the KML or KMZ and it shows the shapes on a map with a count, such as 2 lines and 2 points. Press Convert to Shapefile and it writes one zip with a .shp, .shx, .dbf, .prj and .cpg for each geometry type.

Before you download, it reads its own zip back and compares features, coordinates and attribute values with your KML. Anything it could not carry is named on a Not carried over line. The file stays on your device unless you share it.

A worked example: a smiley over the Salar de Uyuni

  1. Our demo file smiley-uyuni.kml was drawn by a script, not walked: a 10 km circle and a smile as two paths, and two eyes as points, all at 3,656 m over the salt flat in Bolivia.
  2. Drop it into the KML to SHP converter. The panel reads 4 features, 2 lines and 2 points, 24.04 mi. Details shows Lines: 2 lines, 24.04 mi (38.68 km), and the coordinate system WGS 84 (EPSG:4326).
  3. Open the table (More, then Table). It has four columns: name, description, feature_kind and diameter_km.
  4. Press Convert to Shapefile. The panel shows smiley-uyuni.zip, 2.9 KB. A Not carried over line names the KML's document description, which a shapefile has no place for. Then three checks: 4 features, all 90 coordinates (largest difference 0.000 m) and 16 of 16 attribute values.
  5. Unzip it: 10 files. Five belong to smiley-uyuni_lines (the circle and the smile) and five to smiley-uyuni_points (the eyes): .shp, .shx, .dbf, .prj and .cpg for each.
  6. Open the .dbf in your GIS: the columns are now name, descriptio, feature_ki and diameter_k, and diameter_k is a text column. The .cpg says UTF-8, the .prj says WGS 84, and the shapes carry the 3,656 m height as Z values.

Common mistakes

Questions

Can one shapefile hold points and lines together?

No. A shapefile stores features of one geometry type, so points, lines and polygons each need their own shapefile.

Why is my description column called descriptio?

Shapefile field names are limited to 10 characters, so longer names are cut.

Will my KML colours, icons and folders come along?

No. A shapefile has no styles or folders. The converter names what it could not carry on a Not carried over line; set colours again in your GIS.

Which coordinate system will the shapefile use?

WGS 84, the same as the KML, with a matching .prj file. Reproject in your GIS if you need a local grid.

Sample file: smiley-uyuni.kml (a demo drawn by script over the Salar de Uyuni, not a real route) · ours (made by unmake)

Sources

Drop your KML or KMZ into the free unmake KML to SHP converter and download a checked shapefile zip.Try it on your own file