Map to KML (Conversion) |
|
Release 9.3
Last modified November 21, 2008 |
![]() ![]() ![]() Print all topics in : "Tools" |
This converts a map document into a Keyhole Markup Language (KML) file containing a translation of ESRI geometries and symbology. This file is compressed using ZIP compression, will have a .kmz extension, and can be read by any KML client including ArcGIS Explorer, ArcGlobe, and Google Earth.
Usage tips
The output KMZ file cannot already exist.
You can reduce the size of the output KMZ document if your map has scale-dependent renderers and you choose an appropriate map output scale.
To output a single raster image draped over topography, use the Return single composite image option.
To output every layer as a separate raster image, use the Convert Vector to Raster option.
The following environment settings affect this tool: Current workspace, Scratch workspace, and Output extent.
Command line syntax
An overview of the Command Line window
MapToKML_conversion <in_map_document> <data_frame> <out_kmz_file> <map_output_scale> {NO_COMPOSITE| COMPOSITE} {VECTOR_TO_IMAGE | VECTOR_TO_VECTOR} {extent_to_export} {image_size} {dpi_of_client}
Parameter | Explanation | Data Type |
<in_map_document> |
The map document to convert to KML. |
Feature layer |
<data_frame> |
The data frame of the map document to convert to KML. |
Data frame |
<out_kmz_file> |
The KML file to write. This file is compressed and will have a .kmz extension. It can be read by any KML client including ArcGIS Explorer, ArcGlobe, and Google Earth. |
KML file |
<map_output_scale> |
The scale at which to export the map document. Any scale-dependent rendering will be observed, so layers that are not visible at the export scale will not be included in the created KML file. The symbology for the map will be driven by this scale, so if the map has a reference scale defined, it should be considered when setting this parameter. Only numeric characters should be entered. For example, enter the scale as 20000, not 1:20000 or 20,000. Furthermore, if you are exporting a map containing only layers that will be displayed as 3D vectors and there is no scale-dependent rendering defined, then this parameter is not required for the export process and can be set to any numeric value such as 1. |
Double |
{NO_COMPOSITE| COMPOSITE} |
Directs the output KML file to only contain a single image that composes all the features in this map into a single raster image. The raster will be draped over terrain as a KML GroundOverlay. Select this option to reduce the size of the output KMZ file. Individual features and layers will no longer be selectable. |
Boolean |
{VECTOR_TO_IMAGE | VECTOR_TO_VECTOR} |
Converts each vector layer in the map into a separate raster image in the KML output. Normal raster layers will also be added to the KML output. Each output KML raster layer will be selectable, and its transparency can be adjusted in certain KML clients. |
Boolean |
{extent_to_export} |
Choose an extent for the output KML different from that defined by the default map frame. Either define the extent box (in the WGS84 coordinate system) or select a layer or map document that defines an extent using the file selection button and text field. |
Extent |
{image_size} |
Size of returned image (pixels) (optional). Defines the vertical and horizontal resolution of any rasters in the output KML document. |
Long |
{dpi_of_client} |
Defines the device resolution for any rasters in the output KML document. |
Long |
MapToKML '\\myHost\myDocuments\myMap.mxd' 'Layer' '\\myHost\myOutputFiles\myMap.kmz' 24000 COMPOSITE VECTOR_TO_VECTOR '-117 33 -115 35' 1024 96
Scripting syntax
About getting started with writing geoprocessing scripts
MapToKML_conversion (in_map_document, data_frame, out_kmz_file, map_output_scale, is_composite, is_vector_to_raster, extent_to_export, image_size, dpi_of_client)
Parameter | Explanation | Data Type |
in_map_document (Required) |
The map document to convert to KML. |
Feature layer |
data_frame (Required) |
The data frame of the map document to convert to KML. |
Data frame |
out_kmz_file (Required) |
The KML file to write. This file is compressed and will have a .kmz extension. It can be read by any KML client including ArcGIS Explorer, ArcGlobe, and Google Earth. |
KML file |
map_output_scale (Required) |
The scale at which to export the map document. Any scale-dependent rendering will be observed, so layers that are not visible at the export scale will not be included in the created KML file. The symbology for the map will be driven by this scale, so if the map has a reference scale defined, it should be considered when setting this parameter. Only numeric characters should be entered. For example, enter the scale as 20000, not 1:20000 or 20,000. Furthermore, if you are exporting a map containing only layers that will be displayed as 3D vectors and there is no scale-dependent rendering defined, then this parameter is not required for the export process and can be set to any numeric value such as 1. |
Double |
is_composite (Optional) |
Directs the output KML file to only contain a single image that composes all the features in this map into a single raster image. The raster will be draped over terrain as a KML GroundOverlay. Select this option to reduce the size of the output KMZ file. Individual features and layers will no longer be selectable. |
Boolean |
is_vector_to_raster (Optional) |
Converts each vector layer in the map into a separate raster image in the KML output. Normal raster layers will also be added to the KML output. Each output KML raster layer will be selectable, and its transparency can be adjusted in certain KML clients. |
Boolean |
extent_to_export (Optional) |
Choose an extent for the output KML different from that defined by the default map frame. Either define the extent box (in the WGS84 coordinate system) or select a layer or map document that defines an extent using the file selection button and text field. |
Extent |
image_size (Optional) |
Size of returned image (pixels) (optional). Defines the vertical and horizontal resolution of any rasters in the output KML document. |
Long |
dpi_of_client (Optional) |
Defines the device resolution for any rasters in the output KML document. |
Long |
# Purpose: Converts a Map to KML. # Import standard library modules import sys, string, os, arcgisscripting # Create the Geoprocessor object gp = arcgisscripting.create() gp.workspace = "/myHost/myDocuments/" gp.toolbox = "3D" in_map_document = "myMap.mxd" data_frame = "Layer" out_kmz_file = /myHost/myDocuments/myKML_out map_output_scale = "24000" is_composite = "COMPOSITE" is_vector_to_raster = "VECTOR_TO_VECTOR" extent_to_export = "-117 33 -115 35" image_size = "1024" dpi_of_client = "96" try: print 'Converting to KML' gp.maptokml_3d (in_map_document, data_frame, out_kmz_file, map_output_scale, is_composite, is_vector_to_raster, extent_to_export, image_size, dpi_of_client) print 'Finished KML Generation' except: gp.AddMessage(gp.GetMessages(2)) print gp.GetMessages(2)