Select to view content in your preferred language

LayerToKML script execution error ERROR 000210

1738
7
09-10-2020 09:57 AM
AhmadSALEH1
Frequent Contributor

I am trying to write a very simple script that exports a layer to KMZ file using LayerToKML GP tool.

import arcpy

out=r"C:\AhmadData\di\pro\test.kmz"
pLocation=r"C:\AhmadData\di\pro\data5\Data5.aprx"

p = arcpy.mp.ArcGISProject(pLocation)
mp = p.listMaps()[0]


for lyr in mp.listLayers():
                print (lyr.name)


                arcpy.conversion.LayerToKML(lyr,out, 0, "NO_COMPOSITE", "DEFAULT", 1024, 96, "CLAMPED_TO_GROUND")‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

the Data source is file FGDB and Pro map has only one layer with 10 lines features ( the data is very simple) 

the script executed locally on my C drive, but I keep getting this error

arcgisscripting.ExecuteError: ERROR 000210: Cannot create output C:\Users\<USER>\AppData\Local\Temp\{74AB2B10-C6A1-4D89-AB64-FE6CE55D17FE}.lyrx
Failed to execute (LayerToKML).

I checked my local temp folder and I have full Read and Write permissions. my question is why I am getting this error, and why the tool is trying to export the lyrx to the temp folder? 

I tired to set arcpy.env.workspace to point to the project location but it didnt nothing.

I am using ArcGIS Pro 2.5

Thanks

Tags (2)
7 Replies
RandyBurton
MVP Alum

The { and } characters in the filename are not valid.  You need to remove them or provide a different file name.

AhmadSALEH1
Frequent Contributor

Thanks Randy, I dont have any control on the lyrx file name or location, I think its apart of the LayerToKML Geo-processing tool. 

I tired to run the script from Pro Python window and it worked and I can see the file generated in the Temp folder even with {} in the name.

0 Kudos
RandyBurton
MVP Alum

Shouldn't line 5 come before line 2 where pLocation is referenced?

AhmadSALEH1
Frequent Contributor

Yes It should, it might be switched while I am copying and pasting from my script to Geonet
( I updated the code snippet) , thank you for catching it. 

It seems to be a bug in Pro 2.5!

Layer to KML works in Python window but not in Script tool [Update: Bug] 

The script works in  Pro 2.4 , I am going to test on  Pro 2.6 and confirm if it works or not. 

DanPatterson
MVP Esteemed Contributor
redacel_uniredacel_uni
New Contributor

I have the same problem, so the solution is PRO 2.4?

0 Kudos
DanPatterson
MVP Esteemed Contributor

On the link I posted.... BUG-000129805: Running the Layer to KML geoprocessing tool works in.. 

hit the Subscribe link to get updates


... sort of retired...
0 Kudos