Shapefile to KML converter

Drop a zipped shapefile, or its .shp, .dbf and .prj files, and get a KML for Google Earth and Google My Maps. Coordinates are reprojected for you. Free, and no account needed.

Drop a zipped shapefile here

Download the sample

Your file stays on your computer: nothing is uploaded.

In short

Convert Shapefile to KML online, in your browser

SHP in, KML out. The Spatibase Shapefile to KML converter turns an ESRI shapefile (a .zip, or the loose .shp, .dbf, .prj and .cpg picked together) into KML for Google Earth and Google My Maps, in your web browser. On the way:

  • Reprojected from the .prj. UTM, US State Plane, British National Grid and other grids become WGS 84 longitude and latitude, the only system KML allows; ED50, DHDN, Amersfoort and NAD27 get a datum shift.
  • Attributes kept. Every attribute comes along as ExtendedData.
  • Nothing is uploaded. Files up to 50 MB, no account.
How to

How to convert a shapefile to KML

  1. Find all the parts: a shapefile is several files with one name, such as roads.shp, roads.dbf and roads.prj. Open data portals usually hand them out as one .zip.
  2. Drop the .zip on the box above, or press Choose a file and select the .shp, .dbf, .prj and .cpg together. No shapefile at hand? Try the sample: Barcelona in EPSG:25831, the grid Catalan open data uses.
  3. Check the map: if the shapes sit where you expect them, the projection was read right. The notes say if a part was missing.
  4. Press Download KML.
  5. In Google Earth Pro, use File → Open. In Google Earth on the web, open a project and import the KML. In Google My Maps, add a layer and press Import.
What’s kept

What the KML keeps from your shapefile

WhatWhat happens
Points, lines and polygonsKept, each record as a placemark. Multi-part shapes become one placemark with several parts.
CoordinatesReprojected to WGS 84 longitude and latitude using the .prj file.
Old datums (ED50, DHDN, Amersfoort, NAD27)Shifted to WGS 84, so places land within about 5 m. Other old datums get a note that positions may be a few hundred metres off.
Attribute table (.dbf)Every column kept as ExtendedData. Google Earth lists them in the balloon when you click a place.
Place namesA column called name (in any case: NAME, Name) becomes the label you see on the map, and descriptio the description. Other name columns stay in the data.
Column namesUnchanged. They are already at most 10 characters long, because the shapefile cut them.
Several layers in one zipMerged into one KML. Each place keeps its layer’s file name in a folder field.
Colours and symbolsNone to keep: a shapefile stores no styling, so Google Earth draws its default pins, lines and areas.
Formats

What the .prj file does, and why the coordinates change

Most shapefiles aren’t in degrees. Mapping agencies and city portals publish in a local grid measured in metres or feet: a UTM zone, US State Plane, British National Grid (EPSG:27700) or Dutch RD (EPSG:28992). There, Barcelona’s Mercat del Born is at 431758, 4581911.

KML only knows WGS 84. Google Earth wants longitude and latitude in degrees, so the same point has to become 2.174356, 41.403629. The .prj file names the grid, and the converter recalculates every coordinate from it.

No .prj? If the numbers already look like degrees, they are read as WGS 84 and a note says so. If they look like metres, the converter stops and asks for the .prj, because a guess could put your data in the wrong country.

What each part of a shapefile is for:

  • .shp: the shapes. Required.
  • .dbf: the attribute table. Without it, the places have no names or fields.
  • .prj: the coordinate system. Needed unless the data is already in WGS 84.
  • .cpg: the text encoding. Without it, the converter works the encoding out from the .dbf itself.
  • .shx, .sbn, .sbx, .shp.xml: indexes and metadata. Not needed for converting.
Do it in code

Convert a shapefile to KML with ogr2ogr

GDAL’s ogr2ogr (it ships with QGIS) reads the .prj and reprojects to WGS 84 by itself when it writes KML. It can even read the shapefile straight from the zip:

# /vsizip/ reads the shapefile without unzipping it
ogr2ogr -f KML roads.kml /vsizip/roads.zip

# label the placemarks from another column (the default is Name)
ogr2ogr -f KML roads.kml /vsizip/roads.zip -dsco NameField=STREET

Without GDAL: Google Earth Pro opens a shapefile too (File → Open, then set the file type to ESRI Shape), and Save Place As writes the KML. QGIS does it with Export → Save Features As, format Keyhole Markup Language.

FAQ

Questions about converting Shapefile to KML

Which files do I need to convert a shapefile to KML?

The .shp, the .dbf and the .prj with the same name. The .cpg helps with accented text if there is one. Zip them together or select them all at once in the file picker. A .shp alone gives the shapes without names or fields.

Can Google My Maps import a shapefile?

No. My Maps imports KML, KMZ, GPX, CSV and Excel files, not shapefiles. Convert the shapefile to KML here, then add a layer in My Maps and press Import. My Maps takes up to 2,000 features per layer.

Why does my shapefile show up in the wrong place in Google Earth?

Its coordinates are in a projected grid and the .prj was missing or ignored, so the numbers were read as degrees. Convert it here with the .prj included and it is reprojected to WGS 84. ED50, DHDN, Amersfoort and NAD27 data also get the datum shift that would otherwise leave it up to 200 m off.

Will the attribute table survive the conversion to KML?

Yes. Every column goes into the placemark’s ExtendedData with its value, and Google Earth lists them when you click the place. The column names stay as the shapefile had them.

Can I convert a zip with several shapefiles into one KML?

Yes. Every .shp in the zip is read, in any folder, and all of them go into one KML. When the data has no folder column of its own, each place gets one with its layer’s file name.

Does the shapefile leave my computer?

No. The zip or the loose files are read by your browser and converted on your computer. Nothing is sent to Spatibase or anyone else; only the background map comes from the internet.

Moving the places into Spatibase? Read how to import your data. Need another pair of formats? The GIS file converter converts between all of them.

Talk to us

Not sure it’s a fit? Let’s find out

Tell us about your use case and what you need, from data model to security and deployment. In 30 minutes we’ll look at it together and tell you honestly if we can help.

Or write to hello@spatibase.com.