Gis, Qgis, ArcGis  Experts Just a Click Away

How to Convert Shapefile to KML

How to Convert a Shapefile to KML or KMZ

KML and KMZ are convenient formats for sharing geographic data with people who do not use desktop GIS. A converted layer can be opened in Google Earth, ArcGIS Earth, web mapping applications, and other software that supports Keyhole Markup Language.

This guide explains how to convert a shapefile to KML or KMZ with ArcGIS Pro, QGIS, GDAL/OGR, and Python. It also covers the shapefile components you need, WGS 84 coordinate systems, styling, attributes, large files, privacy, and troubleshooting.

Quick answer: In ArcGIS Pro, add the shapefile to a map, confirm or project it to GCS WGS 1984 (WKID 4326 ), run Conversion Tools > KML > Layer To KML, and open the resulting .kmz file in your target application. In QGIS, use Export > Save Features As, choose KML, and set the output CRS to EPSG:4326.

What is a shapefile?

A shapefile is a legacy but widely supported vector format. It stores geometry and attributes across several files that share the same base name:

  • .shp stores the feature geometry;
  • .shx stores the geometry index;
  • .dbf stores the attribute table;
  • .prj stores the coordinate reference system, when available;
  • .cpg can identify the character encoding; and
  • optional index or metadata files may support performance and documentation.

Keep the component files together in the same folder. Selecting only the .shp file may work in some software, but missing .dbf or .prj files can cause lost attributes or an unknown coordinate system.

A shapefile can contain points, multipoints, polylines, or polygons, but one shapefile cannot mix geometry types. Check the geometry type before conversion because it affects how the result appears in Google Earth.

What is KML and what is KMZ?

KML, or Keyhole Markup Language, is an XML-based format for geographic features, styles, labels, folders, links, and some raster imagery. It is designed primarily for visualization and sharing rather than for advanced editing or database management.

KMZ is a compressed ZIP package containing KML and any related resources, such as icons or images. A KMZ file is usually smaller and easier to share than an uncompressed KML file. Many desktop and web applications open KMZ directly.

Use KML when you need a readable XML file or need to inspect the markup. Use KMZ when you want a compact package for distribution. Converting KML to KMZ does not improve the accuracy of the underlying data; it only packages or compresses it.

Before you convert: check the data

Confirm that the shapefile is complete

Place the .shp, .shx, .dbf, .prj, and any encoding file in one folder. If the .prj file is missing, identify the original coordinate system from the data provider or project documentation. Do not guess the CRS from the location alone.

Check the geometry

Open the shapefile in a GIS and inspect the features. Look for missing features, self-intersections, empty geometries, duplicate records, invalid polygons, and unexpected multipart features. A conversion tool may complete successfully even when the source contains geometry problems.

Check the attributes

KML viewers do not necessarily display every field in the same way. Remove fields that are not useful for the recipient, shorten long descriptions, and check text encoding. Keep a copy of the original data before changing field names or values.

Identify the coordinate system

KML and KMZ use geographic WGS 84 coordinates. Esri guidance identifies GCS WGS 1984, WKID 4326, as the required coordinate system for KML/KMZ workflows. If the source uses another datum, use an appropriate geographic transformation rather than only changing the CRS label. 1

Do not use “Set Layer CRS” or an equivalent define-projection operation to reproject data. Defining a CRS changes the metadata assigned to coordinates; it does not transform the coordinates. Use a Project or Reproject operation when the data must be converted to WGS 84.

Method 1: Convert a shapefile to KML in ArcGIS Pro

ArcGIS Pro is useful when you need to preserve a layer’s symbology, labels, scale behavior, and organization. Esri’s Layer To KML tool converts a feature or raster layer to KML or KMZ. 2

Step 1: Add the shapefile to a map

Open an ArcGIS Pro project and add the shapefile to a map. Confirm that it appears in the correct location and that the attribute table opens correctly.

Step 2: Confirm or project the coordinate system

Open the layer properties and inspect the source coordinate system. If it is not GCS WGS 1984, create a projected copy using the Project tool in Data Management Tools > Projections and Transformations. Choose an appropriate geographic transformation when the source datum differs from WGS 1984.

For raster content, use Project Raster when a raster is included. The correct transformation matters because the output location can be wrong when a datum is handled incorrectly.

Step 3: Apply the desired layer appearance

Layer To KML converts a layer rather than only the raw feature class. Apply useful symbology, transparency, labels, and field display settings before running the tool. Keep the display simple for large datasets because complex styling can increase file size and reduce performance.

Step 4: Run Layer To KML

Open the Geoprocessing pane and search for Layer To KML. You can also find it under Conversion Tools > KML.

Set:

  • Layer: the shapefile layer or a group layer;
  • Output File: a .kmz or .kml destination, depending on the tool version and selected options;
  • Layer Output Scale: the scale at which layer detail is represented; and
  • optional image, clipping, or compression settings as appropriate.

Run the tool and inspect the messages. Esri’s support workflow notes that the output is commonly created as a compressed .kmz file. 1

ArcPy example

The simple ArcPy form can be used after creating a layer with the desired symbology:

import arcpy

input_shapefile = r"C:\GIS_Data\Project\roads.shp"
output_kmz = r"C:\GIS_Data\Project\roads.kmz"

arcpy.env.overwriteOutput = True
arcpy.management.MakeFeatureLayer(input_shapefile, "roads_layer")

arcpy.conversion.LayerToKML(
    in_layer="roads_layer",
    out_kmz_file=output_kmz,
    layer_output_scale=0
)

print(f"Created: {output_kmz}")

The exact optional parameters can vary by ArcGIS Pro release. Use the tool’s installed help or arcpy.help("LayerToKML") to inspect the full signature before building a production script.

Method 2: Convert a shapefile to KML in QGIS

QGIS is a free and open-source option that runs on Windows, macOS, and Linux. It is a good choice when you do not have ArcGIS Pro access or need a cross-platform workflow.

Step 1: Add the shapefile

Open QGIS and choose Layer > Add Layer > Add Vector Layer. Browse to the .shp file and add it to the map. Confirm the layer appears in the expected location.

Step 2: Check the source CRS

Right-click the layer and open Properties > Information or Source. Identify the current CRS. If the layer is not already in WGS 84, export a reprojected copy:

  1. Right-click the layer.
  2. Choose Export > Save Features As.
  3. Set the output format to a suitable temporary format or KML directly.
  4. Set the CRS to EPSG:4326 – WGS 84.
  5. Choose the output file and save it.

Use the export operation to transform the coordinates. Do not simply assign EPSG:4326 to a layer whose coordinates are actually in a local projected system.

Step 3: Export to KML

Right-click the layer and select Export > Save Features As. Set Format to a KML option, choose an output filename, select EPSG:4326, and choose the fields to include if the dialog provides field selection. Click OK.

QGIS styling support can depend on the export provider and the target viewer. Check points, lines, polygons, labels, and transparency in the resulting file rather than assuming that every desktop style will transfer exactly.

Step 4: Open and verify the output

Open the KML or KMZ in Google Earth, ArcGIS Earth, or another target application. Check the feature location, geometry, labels, fields, symbols, and folders. A successful save dialog does not guarantee that the result will look identical in every KML viewer.

Method 3: Convert with GDAL/OGR

GDAL/OGR is useful for batch jobs, servers, reproducible scripts, and command-line workflows. The ogr2ogr command can transform the source to KML and reproject it to EPSG:4326.

ogr2ogr \
  -f KML \
  -t_srs EPSG:4326 \
  output.kml \
  input.shp

To select fields, use the syntax supported by the installed GDAL version. One commonly used form is:

ogr2ogr \
  -f KML \
  -t_srs EPSG:4326 \
  -select NAME,TYPE \
  output.kml \
  input.shp

Check ogr2ogr --help because option support and KML driver behavior can differ by build. If the source uses a different datum, specify the appropriate transformation or prepare a correctly projected intermediate dataset.

GDAL is particularly useful when converting many files. Keep input and output folders separate, log failures, and validate a sample of files in the target viewer.

Method 4: Automate conversion with Python

Python automation is useful when the same conversion must be performed repeatedly. There are several possible libraries, and KML writing depends on the installed GDAL driver and Python package configuration. Test the driver before relying on a script.

A GeoPandas workflow may look like this when the installed environment supports a KML writer:

import geopandas as gpd

input_path = "input.shp"
output_path = "output.kml"

gdf = gpd.read_file(input_path)

if gdf.crs is None:
    raise ValueError("The shapefile has no CRS; identify it before converting.")

gdf = gdf.to_crs("EPSG:4326")
gdf.to_file(output_path, driver="KML")

If the script raises a driver or unsupported-format error, use GDAL/OGR or a QGIS processing environment instead. Do not remove the CRS check. Reprojecting from an incorrectly identified CRS produces incorrect output even if the file saves successfully.

For repeated enterprise workflows, use a pinned environment, record package versions, write a conversion log, and test output locations and attributes automatically.

Converting multiple shapefiles into one KMZ

In ArcGIS Pro, add the layers to a map and group them in a group layer before running Layer To KML. This can preserve a folder structure in the result and make the output easier to browse.

In GDAL, process each layer into its own KML or build a controlled KML document. In QGIS, export each layer separately or use a project-level workflow if the desired output requires several layers and styles.

Do not combine unrelated layers merely because they are in the same project. Name folders and layers clearly, remove unnecessary fields, and tell recipients what CRS and date the data represents.

KML styling and attribute limitations

KML supports names, descriptions, styles, icons, line colors, polygon fills, visibility settings, folders, and some altitude behavior. GIS symbology does not always map one-to-one to KML styling.

Common limitations include:

  • complex symbol layers may be simplified;
  • class breaks may not transfer exactly;
  • labels may use different font behavior;
  • field aliases and long field names may be changed;
  • nulls and dates may display differently;
  • geometry with curves or advanced GIS properties may be converted; and
  • some viewer applications support only part of the KML specification.

Create a simple target-focused style. If the purpose is visual communication, include only fields that recipients need in the pop-up or description. If the purpose is analysis, KML may not be the best delivery format; provide GeoPackage, GeoJSON, a geodatabase, or another analysis-ready format as well.

File size and performance

Large shapefiles can create slow or unusable KML files. Detailed coastlines, building footprints, dense GPS tracks, and nationwide boundaries may contain millions of vertices.

To reduce size and improve display performance:

  1. Clip the data to the area the recipient needs.
  2. Remove fields that are not needed.
  3. Simplify geometry while preserving the required accuracy.
  4. Reduce the number of features when a generalized layer is acceptable.
  5. Use KMZ compression for distribution.
  6. Split very large datasets into logical regions or themes.
  7. Use scale-dependent display or a network-link strategy when supported.
  8. Keep an analysis-ready source format separate from the visualization copy.

Do not simplify data without documenting the tolerance and intended use. A file optimized for visual overview should not be used for precision measurement or legal boundary work.

Troubleshooting common conversion problems

The output appears in the wrong location

Check the source .prj file and identify the actual CRS. Reproject the data to EPSG:4326 using a correct datum transformation. Do not assign WGS 84 to data that is merely labeled incorrectly.

The shapefile has no attributes in KML

Confirm that the .dbf file is present and readable. Check field names, encoding, null values, and the export field list. Some viewers show attributes only after opening a feature’s information panel.

The KML file is blank

Check that the layer contains features, that the features are within the map extent, and that the geometry type is supported. Open the KML in a second viewer to determine whether the problem is the file or the application.

Symbols or labels look different

KML and GIS applications do not share identical rendering engines. Use simple points, lines, polygon fills, and labels. Verify the result in the application used by the recipient.

The output is too large

Clip, simplify, remove fields, split by area, and use KMZ. If the result is still too large, provide a web map or tiled visualization instead of a single monolithic KML.

Online conversion is not appropriate

Do not upload confidential, personal, unpublished, or restricted data to an online converter unless the provider is approved for that data. Use a local desktop or command-line workflow when privacy, compliance, or chain of custody matters.

Coordinates are slightly shifted

A datum transformation or incorrect source CRS may be responsible. Compare a known control feature in both the source and output. Check whether the source uses a local datum and whether the converter applied the correct transformation.

KML versus other output formats

KML is best for visualization and sharing with Earth browsers. Consider another format when the recipient has a different need:

  • GeoJSON: web development and lightweight feature exchange;
  • GeoPackage: modern single-file GIS storage and analysis;
  • GeoParquet: analytics and large tabular-geospatial workflows;
  • GPX: GPS tracks, routes, and waypoints;
  • Shapefile: legacy interoperability, with known field and file limitations; and
  • File geodatabase: ArcGIS-oriented analysis and data management.

Providing both KML/KMZ and an analysis-ready format often avoids forcing one file type to serve incompatible purposes.

Quality-control checklist

Before delivering a converted file, verify:

  • all required shapefile sidecar files were available;
  • the source CRS was identified correctly;
  • the output uses WGS 84 geographic coordinates;
  • any datum transformation was appropriate;
  • points, lines, or polygons appear in the correct location;
  • expected attributes are visible;
  • styles and labels are readable;
  • the file opens in the recipient’s target application;
  • the file size is reasonable; and
  • the source date, CRS, and processing method are documented.

Keep the original shapefile and a record of the conversion settings. KML is a delivery format, not a replacement for the source dataset.

Frequently asked questions

How do I convert a shapefile to KML?

Use ArcGIS Pro’s Layer To KML tool, QGIS’s Export > Save Features As workflow, GDAL’s ogr2ogr, or a tested Python environment. Reproject to EPSG:4326 and verify the result in the target viewer.

What is the difference between KML and KMZ?

KML is an XML file. KMZ is a compressed package containing KML and possibly related resources. KMZ is usually smaller and easier to distribute.

Do I need all shapefile files to convert it?

Yes. Keep the .shp, .shx, .dbf, and .prj together. The .prj is especially important for identifying the coordinate system, while the .dbf stores attributes.

What CRS should a KML use?

KML/KMZ workflows use geographic WGS 84, commonly identified as EPSG:4326 or WKID 4326. Reproject the coordinates rather than simply changing the CRS label. 1

Can I convert a shapefile to KML without ArcGIS?

Yes. QGIS and GDAL/OGR are free alternatives. Python can automate the task when the installed geospatial drivers support KML output.

Can Google Earth open a shapefile directly?

Google Earth generally expects KML or KMZ rather than a complete shapefile dataset. Convert the layer and verify the result before sharing.

Why is my KML larger than the original shapefile?

KML is XML and may contain repeated coordinates, descriptions, and style definitions. Use KMZ compression, simplify geometry, remove unnecessary fields, or split the data.

Are KML coordinates the same as shapefile coordinates?

Not necessarily. KML uses geographic WGS 84 coordinates, so a projected or local shapefile must be transformed. The displayed location should remain correct when the source CRS and transformation are handled properly.

Decide whether KML is the right delivery format

KML is a good choice when the recipient needs to view locations in Google Earth or another Earth browser. It is less suitable when the recipient must edit attributes, run spatial analysis, preserve geodatabase domains, or measure features with survey-level accuracy. In those cases, deliver the original or a modern analysis-ready copy alongside the KML.

Also clarify whether coordinates represent ground locations, lines, or polygon boundaries and whether heights should be clamped to the ground or interpreted as absolute altitude. Most basic shapefile exports are intended for two-dimensional viewing. If the project depends on 3D heights, test the altitude settings in the target application and document the vertical reference.

Summary

Converting a shapefile to KML or KMZ is straightforward when the source data is complete, the coordinate system is known, and the output is designed for visualization. ArcGIS Pro is convenient when you need Esri layer symbology and a project workflow. QGIS is a strong free cross-platform option. GDAL/OGR and Python are useful for repeatable batch processing.

The most important steps are to preserve the shapefile sidecar files, transform the data to WGS 84 correctly, simplify or filter large datasets when necessary, and verify the output in the application your audience will use. Keep the original shapefile and provide an analysis-ready format when recipients need more than a visual KML display.

References

[1] Esri: A Farewell to ArcMap

[2] Esri: ArcGIS for Student Use

[3] QGIS official website

[4] QGIS official download page

Leave a Reply

Gabby Jones

Typically replies within a minute

Hello, Welcome to the site. Please click below button for chating me throught WhatsApp.