problem  with LayerToKML_conversion tool in python

5637
15
08-17-2014 10:53 PM
NaimeCelik
Occasional Contributor

Hello,

 

I am trying to convert some layers, to kml in python IDLE. I used arcpy.LayerToKML_conversion . In ArcMap it works fine and you can convert each layer to kml without  any problem.However when I use it in python script, only first runing result of tool creates the correct location in kml file  and all other layers run inside "for loop" appear in 0 N and 0 S Geographic Coordinates. It is so weird, I checked the layers (.lyr  files) in ArcMap,they are all in correct location. If I close IDLE and only run one file it works, without closing the idle second attempt of running same script with same data will give  in 90° N and 180° EGeographic Coordinates.

 

I would greatly appreciate if someone tries this tool in python and let me know what they get.

 

Thank you so much,

 

Naime

0 Kudos
15 Replies
DanPatterson_Retired
MVP Emeritus

nothing is attached...was there supposed to be?

0 Kudos
NaimeCelik
Occasional Contributor

Hello,

Thanks for your interest on my post, I am still trying to solve this problem but no luck,

I attached a simple script and sample data for you to try. You need to change the path of the data before running.

I also add results that I obtained. The first results  kmz called testdata0 is in correct location but others appears on arctic ocean.. Not sure what is going on..

Thank you so much..

Naime

0 Kudos
AndrewChapkowski
Esri Regular Contributor

When you save the layer file, make sure you store it using relative path names.  I think that was the issue.

0 Kudos
NaimeCelik
Occasional Contributor

Hello,

Thanks for your advice, unfortunately, this was not the problem, I saved file with "RELATIVE" but still second runs appears in arctic ocean.. I cannot figure out what is happening., seems like something related to LayertoKML tool

0 Kudos
NaimeCelik
Occasional Contributor

Hello,

I have been trying to solve this problem and contacting to Esri Costumer Service in that issue. They told me tool  works fine, they do not have any problem. I have been very frustrated  I tried other people's computer at the office and the results were as I explained above and do not understand that how it does work fine for ESRI folks .

I am using 10.2.1 in office and I tried the script in 10.1 ( in home computer) and some reason the results in 10.1 were correct. It turned out the problem stems from ArcGIS version  and have no idea want is going on...

Can any one try the script for me if they have ArcGIS 10.2 version or later ?

Below I attached a rar  it has the sample data.

1. Open LayerToKML rar in  C:\Temp

2. Open the lyr file in the arcmap and make sure it is not broken, if so open the shp and save the shp as layer (overwrite the layername).

3. Then by using Python IDLE ( under All programs-ARCGIS) open the test script and run module

It will run the inside Outputs and could you please send those to me with a rar file.

I would greatly appreciate that.

0 Kudos
NaimeCelik
Occasional Contributor

Ok, I had somebody test this for me with ArcGIS 10.2.1 and it works fine on their program. Now only difference is the fact that I had my ArcGIS with 64 bit bacground-geoprcessing installed. Seems like that might be the problem.

I uninstall arcgis and install the software again and still getting same issue.. Maybe uninstalling is not enough to go back to 32bit geoprocessing,is  it possible somehow at registry it is still getting paths to run tools from 64 bits ?

0 Kudos
AndreasPonn
New Contributor

Hello Naime,

Did you ever solve your problem? I have exactly the same. The first kmz-file is in correct location, the other lay around the world. The problem occur only in python scripts. When I convert layer files in ArcMap with the same geoprocessing tool that I use in python, the location of all kmz-files is correct.

Thanks

Reinhild

0 Kudos
NaimeCelik
Occasional Contributor

Unfortunately, could not solved the problem, the customer service even refusing to accept tthere is a problem. They kept saying they do not have problem when they try on their computer.

How ever I am suspicious about 64 bit background-geoprocessing, when you install your ArcGIS software, did you install  64 bit background-geoproscessing afterward?

0 Kudos
DavidBlanchard
Esri Contributor

I took a look at your code and gave it a try, but I was never able to get it to run as expected when reading directly from the .lyr file. I modified your code to first create a Feature Layer using the MakeFeatureLayer tool. This worked for me regardless of how many times it looped through the same file.

I tested this approach on 3 different boxes:

  • 10.2.2 + 64bit GP - Windows 7 64bit
  • 10.1 - Windows 7 32bit
  • 10.1 + 64bit GP - Windows 7 64bit

and in all three cases, the modified script worked, outputting a KMZ with all points in the same location as the original shapefile.

If this fails to solve your problem, there may be something specific to your environment, or your installation of Python that is causing this issue. You may want to make sure you are running the script with Python 2.7 when using IDLE.

0 Kudos