Simple question with hopefully a nuts and bolts data type response, but I am confused. I just wrote a script to convert feature classes to KML. Seemingly same parameters as all the conversion tools --> SomeConversionTool_conversion(feature_class_to_convert, converted_layer_new_name_or_format.ext)
But in the case of LayerToKML_conversion it's erroring out I because I NEED a map open and simply the Layer passed as first argument. WHY? All other conversion tools allow a path to the feature? And Dear ESRI, excellent job with the informative Exceptions. But I did successfully run the tool in a Notebook using arcpy.LayerToKML_conversion('layer name in current map', fp_out_kml.kml').
Is there a workaround to make scriptable versions without having to load up all data as Layers in a map. And...Why Not?
Thank - Zach
Solved! Go to Solution.
Either a layer in the map or a *.lyrx on disk
In short it wants a layer, which means if you wanted to use a featureclass in the tool, you would have to embed a behind the scenes MakeFeatureLayer to feed into your conversion.
Kind of kludgy? perhaps, but maybe it is demand driven. Post an Idea, or look for an existing one to see if there is widespread use of kml/z and whether direct conversion from featureclasses to kml is in demand
Zachary - a workaround I came up with is to create a *.lyrx for the feature class in question. Then use the *.lyrx file as the input parameter for Layer. The GP tool will process correctly and not throw the ERROR 000584. Not an ideal solution granted but it does work.
For this time around I'm going with in memory lyr. Lyrx actually may be a nice solution under a different task, and honestly not a bad idea to start creating .lyrx files for bread and butter data. Glad you planted the seed!
Either a layer in the map or a *.lyrx on disk
In short it wants a layer, which means if you wanted to use a featureclass in the tool, you would have to embed a behind the scenes MakeFeatureLayer to feed into your conversion.
Kind of kludgy? perhaps, but maybe it is demand driven. Post an Idea, or look for an existing one to see if there is widespread use of kml/z and whether direct conversion from featureclasses to kml is in demand
That works Dan. Thanks. I was hoping there was a way to avoid creating lyrs but apparently not. Post an idea you say? I've seen this before yet never contributed. Just bellyache and criticize. Perhaps I will for this one...
Both @DanPatterson and @Robert_LeClair had great solutions, but I wanted to incorporate solution programmatically withOUT having to create extra lyrx files, hence going with Dan's solution. Thanks!