Map To KML (Conversion)


Converts a map to a KML file containing geometries and symbology. The output file is compressed using ZIP compression, has a .kmz extension, and can be read by any KML client including ArcGIS Earth and Google Earth.

Learn more about KML support in ArcGIS


  • You can control the appearance of KML in the following two ways:

    • By default, the pop-up display is composed of all visible fields from the layer. Pop-up displays can also be set using the layer's customized pop-ups. If the layer pop-ups have not been customized, the values in the feature layer's PopupInfo field are shown in the pop-up when a KML feature is clicked. These values can be numeric or text attributes as well as HTML code stored in a text field.
    • When the layer properties are not set and the feature class contains certain attributes (fields), the field properties are used in creating the KML layers that were originally created using the KML To Layer tool including attributes that define how KML is created. See KML conversion for more information about creating KML from attributes.

  • You can reduce the size of the output KMZ document if your map has scale-dependent layer display properties and you choose an appropriate map output scale.

  • All .kml and .kmz files are created in the WGS84 coordinate system. Ensure that your layers will properly project if they aren't in WGS84. You can use the Project tool to reproject your data prior to KML conversion if your projection requires a transformation.

  • To output a single raster image draped over topography, use the Return single composite image parameter.

  • To output every layer as a separate raster image, use the Convert Vector to Raster parameter.

  • The Map Output Scale and Size of returned image (pixels) parameters are used together to create tiled output. For example, for an image with a size of 7000 by 5000 pixels, and a Size of returned image (pixels) parameter value of 1000 pixels, the output image will be composed of 7 x 5, or 35, subimages. If the Map Output Scale parameter value is set to 1, each subimage will be 1000 by 1000 pixels. If the Map Output Scale parameter value is set to 10, each subimage will be 100 by 100 pixels.


arcpy.conversion.MapToKML(in_map, out_kmz_file, {map_output_scale}, {is_composite}, {is_vector_to_raster}, {extent_to_export}, {image_size}, {dpi_of_client}, {ignore_zvalue})
ParameterExplanationData Type

The map, scene or basemap to convert to KML.


The output KML file. This file is compressed and has a .kmz extension. The file can be read by any KML client including ArcGIS Earthand Google Earth.


The scale at which to export each layer in the map.

This parameter is important with any scale dependency, such as layer visibility or scale-dependent rendering. If the layer is not visible at the output scale, it is not included in the output KML. Any value, such as 1, can be used if there are no scale dependencies.

For raster layers, a value of 0 can be used to create one untiled output image. If a value greater than or equal to 1 is used, it determines the output resolution of the raster. This parameter has no effect on layers that are not raster layers.

Only numeric characters are accepted; for example, enter 20000 as the scale, not 1:20000. In languages that use commas as the decimal point, 20,000 is also acceptable.

If you're exporting a layer that is to be displayed as 3D vectors and the is_composite parameter is set to NO_COMPOSITE, you can set this parameter to any value as long as your features do not have any scale-dependent rendering.


Specifies whether the output KML contains a single composite image or separate layers.

  • COMPOSITEThe output KML contains a single image that composites all the features in the map into a single raster image. The raster is draped over the terrain as a KML GroundOverlay. This option reduces the size of the output KML file. When you choose this option, individual features and layers in the KML are not selectable.
  • NO_COMPOSITEThe KML contains separate, individual layers. This is the default. Whether the layers are returned as rasters or as a combination of vectors and rasters is determined by the is_vector_to_raster parameter.

Specifies whether each vector layer in the map is converted to a separate raster image or preserved as vector layers.

This parameter is disabled if the is_composite parameter is set to COMPOSITE.

  • VECTOR_TO_IMAGEVector layers are converted to a separate raster image in the KML output. Normal raster layers are also added to the KML output. Each output KML raster layer is selectable, and its transparency can be adjusted in certain KML clients.
  • VECTOR_TO_VECTORVector layers are preserved as KML vectors. This is the default.

The geographic extent of the area to be exported. Specify the extent rectangle bounds as a space-delimited string of WGS84 geographic coordinates in the form left lower right upper (x-min, y-min, x-max, y-max).

  • MAXOF—The maximum extent of all inputs will be used.
  • MINOF—The minimum area common to all inputs will be used.
  • DISPLAY—The extent is equal to the visible display.
  • Layer name—The extent of the specified layer will be used.
  • Extent object—The extent of the specified object will be used.
  • Space delimited string of coordinates—The extent of the specified string will be used. Coordinates are expressed in the order of x-min, y-min, x-max, y-max.

The size of the tiles for raster layers if the Map Output Scale parameter value is set to a value greater than or equal to 1. This parameter only has an effect on raster layers.


The device resolution for any rasters in the output KML document. Typical screen resolution is 96 dpi. If the data in your map supports a high resolution and your KML requires it, consider increasing the value. Use this parameter with the Size of returned image (pixels) parameter to control output image resolution. The default value is 96.


Specifies whether features are clamped to the ground.

  • CLAMPED_TO_GROUND The z-values of the features are overridden and KML is created with the features clamped to the ground. The features are draped over the terrain. This setting is used for features that do not have z-values. This is the default.
  • ABSOLUTEThe z-values of the features are used when creating KML. The features are drawn inside KML clients relative to sea level.

Code sample

MapToKML example 1 (Python window)

The following Python window script demonstrates how to use the MapToKML function in immediate mode.

import arcpy
arcpy.env.workspace = "C:/data"
arcpy.MapToKML_conversion("cities.mapx", "cities.kmz")
MapToKML example 2 (stand-alone script)

The following Python script demonstrates how to use the MapToKML function in a stand-alone script.

# Import system modules
import arcpy

# Set environment settings
arcpy.env.workspace = "C:/data"

# Use ListFiles to identify all map files in workspace
files = arcpy.ListFiles('*.mapx') 
if len(files) > 0:
    for map_file in files:
        # Set Local Variables
        composite = 'NO_COMPOSITE'
        vector = 'VECTOR_TO_VECTOR'
        pixels = 2048
        dpi = 96
        clamped = 'ABSOLUTE'
        for scale in range(10000, 20000, 30000):
            # Strips the '.mapx' part of the name and appends '.kmz'
            outKML = map_file[:-5]+'.kmz'

            #Execute MapToKML	
            arcpy.MapToKML_conversion(map_file, outKML, scale, composite, 
                                      vector, '', pixels, dpi, clamped)
    arcpy.AddMessage('There are no map files (*.mapx) in {}'.format(arcpy.env.workspace))


This tool does not use any geoprocessing environments.

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes

Related topics