← Back to Blog

How to Convert Shapefile to KML: 3 Easy Methods

March 6, 2026 · ConvertGeoData Team

How to Convert Shapefile to KML: 3 Easy Methods - Hero

Need to convert a Shapefile to KML so you can view your GIS data in Google Earth? You're in the right place. Whether you're sharing field survey results with a client, publishing geographic data for public viewing, or simply prefer the 3D visualization that Google Earth offers, converting SHP to KML is one of the most common geospatial tasks around. In this guide, we'll walk through three proven methods to convert SHP to KML, and cover important details like styling, altitude modes, and attribute mapping.

What Are Shapefile and KML Formats?

Before diving in, let's quickly review the two formats. A Shapefile is a vector data format developed by Esri. It actually consists of multiple files (.shp, .shx, .dbf, and optionally .prj, .cpg, and others) that together store geometry and attribute data. Shapefiles are the workhorse of the GIS world and are supported by virtually every GIS application.

KML (Keyhole Markup Language) is an XML-based format originally developed for Google Earth. It supports points, lines, polygons, and even 3D features with altitude information. KML files can include styling (colors, icons, line widths), descriptions with HTML, and organized folder structures. Because KML is designed for visualization, it's ideal for sharing maps with non-GIS users who have Google Earth or Google Maps.

Method 1: Convert Shapefile to KML Online

The fastest way to convert SHP to KML online is to use a web-based converter like ConvertGeoData.com. No software installation is needed, and the process takes just a few clicks.

Steps:

  1. Go to ConvertGeoData.com.
  2. Upload your Shapefile. Remember that a Shapefile consists of multiple files, so you'll typically upload a .zip archive containing the .shp, .shx, .dbf, and .prj files together.
  3. Select KML as the output format.
  4. Click Convert and download the resulting .kml file.

This method is perfect for quick, one-off conversions. It handles coordinate reprojection automatically (KML requires WGS 84 / EPSG:4326), so you don't need to worry about your source projection.

Online converters make Shapefile to KML conversion simple and fast.

Method 2: Convert SHP to KML Using QGIS

If you need more control over the output, QGIS is an excellent free and open-source option. QGIS gives you full control over styling, attribute selection, and coordinate systems before exporting.

Steps:

  1. Open QGIS and load your Shapefile by dragging it into the map canvas or using Layer > Add Layer > Add Vector Layer.
  2. Style your layer as desired (colors, labels, line widths). These styles can carry over into the KML output.
  3. Right-click the layer in the Layers panel and select Export > Save Features As...
  4. In the Format dropdown, choose Keyhole Markup Language (KML).
  5. Set the CRS to EPSG:4326 (WGS 84) if it isn't already selected.
  6. Choose a file name and location, then click OK.

Tip: In the export dialog, you can check "Symbology export" to include your QGIS styling in the KML file. This means your colors and line styles will appear when the file is opened in Google Earth.

Method 3: Convert SHP to KML with ogr2ogr

For batch processing or scripting workflows, ogr2ogr from the GDAL/OGR library is the go-to command-line tool. It's fast, scriptable, and handles large datasets efficiently.

Basic command:

ogr2ogr -f "KML" output.kml input.shp

That's it for a simple conversion. GDAL automatically reprojects to WGS 84 when writing KML. To select specific attributes or rename them, you can use the -sql flag:

ogr2ogr -f "KML" output.kml input.shp -sql "SELECT name, population FROM input"

For batch conversion of multiple Shapefiles in a folder, a simple shell loop does the job:

for f in *.shp; do
  ogr2ogr -f "KML" "${f%.shp}.kml" "$f"
done

Styling Your KML Output

One of the biggest advantages of KML over Shapefile is its built-in support for visual styling. When you convert Shapefile to KML, you can control how features appear in Google Earth.

Key styling options include:

  • Colors: KML uses AABBGGRR hex format (note: the order is alpha, blue, green, red, which is different from standard HTML colors).
  • Icons: Point features can use custom icons via a URL reference in the KML's <IconStyle> element.
  • Line width and polygon fill: Controlled through <LineStyle> and <PolyStyle> elements.
  • Labels: Use <LabelStyle> to control feature name display on the map.

If you're using QGIS, style your layer before exporting and enable symbology export. If you're using ogr2ogr, you may need to edit the KML file afterward or use an OGR style string with the -dsco options.

Understanding KML Altitude Modes

KML supports several altitude modes that control how features are positioned vertically in Google Earth. This is especially important for 3D visualization.

Common altitude modes:

  • clampToGround: Features are draped on the terrain surface. This is the default and works well for most 2D data.
  • relativeToGround: Features are placed at a specified height above the ground. Useful for showing building heights or flight paths.
  • absolute: Features are placed at an exact altitude above sea level, regardless of terrain.

Most Shapefiles contain 2D data, so clampToGround is usually the right choice. If your Shapefile has Z-values (3D geometry), you can preserve them during conversion. In ogr2ogr, the Z-values are carried over automatically when present.

Attribute Mapping: Keeping Your Data Intact

When you convert SHP to KML, your attribute data from the .dbf file is mapped into KML's <ExtendedData> element. Each attribute becomes a <SimpleData> field. Google Earth displays these attributes in a pop-up balloon when you click on a feature.

A few things to keep in mind:

  • Field name length: Shapefile field names are limited to 10 characters. KML has no such limit, but the truncated names from the Shapefile will carry over unless you rename them.
  • Character encoding: Make sure your .cpg file specifies the correct encoding (usually UTF-8). Otherwise, special characters in attribute values may appear garbled in the KML.
  • Description templates: KML allows you to create HTML description balloons using <BalloonStyle>. After conversion, you can edit the KML to add formatted pop-ups that display attributes in a user-friendly layout.
Attribute data transfers from Shapefile to KML as ExtendedData fields.

Common Issues and Troubleshooting

Here are some problems you might encounter when converting Shapefile to KML, along with solutions:

  • Features appear in the wrong location: This usually means the Shapefile's .prj file is missing or incorrect. Make sure your source data has a valid projection defined. The converter needs this information to reproject to WGS 84.
  • Missing attributes: Verify that your .dbf file is included alongside the .shp and .shx files. Without it, attribute data won't transfer.
  • Large file size: KML is XML-based and can be significantly larger than the equivalent Shapefile. For large datasets, consider using KMZ (a zipped KML) to reduce file size. In ogr2ogr, simply change the output extension to .kmz or use -f "LIBKML" for KMZ support.
  • Encoding issues: If you see garbled text, check the character encoding of your source data and include a .cpg file set to UTF-8.

Tips for Best Results

To get the most out of your Shapefile to KML conversion, keep these tips in mind:

  • Always include the .prj file in your Shapefile package. This ensures correct reprojection to WGS 84.
  • Simplify complex geometries before converting if the KML will be used in Google Earth. Highly detailed polygons can cause performance issues in the viewer.
  • Use KMZ for sharing. It bundles the KML with any referenced resources into a single compressed file.
  • Test in Google Earth after conversion. Open the file and verify that features, attributes, and styling all look correct.
  • Organize with folders. KML supports folder structures. If you're combining multiple layers, use folders to keep things tidy.

Ready to Convert Your Shapefile to KML?

Converting Shapefile to KML doesn't have to be complicated. For quick conversions with no software to install, head over to ConvertGeoData.com and convert your SHP to KML in seconds. For more advanced workflows involving custom styling, altitude modes, or batch processing, QGIS and ogr2ogr have you covered.

No matter which method you choose, the key steps are the same: ensure your Shapefile is complete (all required files included), verify the projection, and check your output in Google Earth. Happy mapping!

Shapefile KML Google Earth GIS Conversion ogr2ogr