I am fairly new to GIS and have what is probably a simple problem, but I cannot figure out how to solve it.
I need to convert data from a .MXD file into KML. Doing this using ArcMap is a fairly simple task. I can even understand the steps to run in Python which are simple enough. However, I have no idea how to get all the data from the .MXD file into my workspace prior to running the conversion.
I have used the example script that is provided in the desktop help and included it below. What I seem to be missing is that in their example, they simply load the .mxd file as the "in_map_document" parameter. I tried this, replacing the "myMap.mxd" with our own file and, though it does return a small amount of data, it is completely useless.
What I need to do is actually open the .mxd file into a workspace as there are a number of queries that need to run to retrieve information from the DB prior to doing the MapToKML conversion.
I have searched high and low for this and even searched these forums, but no luck. My apologies if this has been answered in a previous post.
Thanks.
The example script is as follows:
----------------------------------------------
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)