problem  with LayerToKML_conversion tool in python

5715
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
NaimeCelik
Occasional Contributor

Thanks for your try. I have a additional question. Do you have ARCGIS 64 bit geoprocessing path installed?

The link below shows a thread about that.

ArcGIS 10.2 Installation for 64-bit geoprocessing - Geographic Information Systems Stack Exchange

If you had that in computer, ArcGIS is going to work with 64 bit instead of default setting of 32 bit and your arcgis python path will be like C:\Python27\ArcGISx6410.2 – (64-bit) instead of C:\Python27\ArcGIS10.2 – (32-bit).

If you have not installed that and your tool is working fine that means  I think the problem definitely stems from installing 64 bit geoprocessing ArcGIS patch.

I would greatly appreciate if you could let me know if your ARCGIS working as  32 or 64 bit.

Thanks 

0 Kudos
DavidBlanchard
Esri Contributor

As I described in my previous response, I tested it on three computers:

  • 10.2.2 + 64bit GP - Windows 7 64bit
  • 10.1  - Windows 7 32bit (therefore no 64bit GP)
  • 10.1 + 64bit GP - Windows 7 64bit

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

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 (it is possible to have several versions of Python running side-by-side).

You can always try adding a short delay at the beginning of your loop. This would give Python more time to terminate previous processes and close open files. I would also suggest using a File Geodatabase Feature Class instead of a shapefile given that it's a more modern framework and is the format used by most organizations internally. Lastly, if you are storing/saving data on a network drive, please move it to your local drive as network delayed writing can have a negative impact on GP tools.

Otherwise, I'm an end-user like you so I cannot make any IT specific suggestions, which could be the problem given that this is unique to your machine.

NaimeCelik
Occasional Contributor

Hello, I also just tried the attachment you have added. Only the first results ( FLayer0.kml) in correct location the other two (FLayer1 and FLayer2) appeared in the middle of arctic ocean as I experienced before.

0 Kudos
FrancisMoisan
New Contributor II

Hi!

I have the same problem.  The first time I run my script, the KMZ is fine but the second time the KMZ wrap the world.  When I unzip de kMZ, the coordinate of the geometry use bad decimal delimiter.

First run : -72.5123508930792,46.02718407088821,0 -72.89026165964782,45.9512204096942,0 -73.00197113196214,45.60643088717575,0

Second run : -72,5123508930792,46,02718407088821,0 -72,89026165964782,45,9512204096942,0 -73,00197113196214,45,60643088717575,0

I have to close arcmap, and then open it back and then it works fine for the first run and the second run is bad geometry...

I try to change the windows local setting to (decimal delimiter) to point and the tool works fine 

But I can't change my local setting permanently.  I have to use a comma as a decimal delimiter (french canada).

So I try the python "locale" to change the setting on the fly but with no success.

Any idea?

Thanks!

Francis

JosephDavies
New Contributor III

Hi Francis,

I am having the same problem. My script works fine in arcmap, but when i publish it to server only the first run works. After that, the coordinates are generated with commas. Permanently changing the local setting is not an option.

Were you able to solve the problem?

Thanks,

Joe

0 Kudos
FrancisMoisan
New Contributor II

Hi Joe,

Instead of using the ArcGIS Tool, I made my own export to kml tool in python.  In my code there is a section for point, polygon and line (base on what the tool receive as input).  I'm not a programmer so the code is not very clean.  It's not perfect and I can't bring attribut to kml in my code.  The only thing that works is the geometry I draw in flex viewer is exporter to KML nicely.  And the selected object can be exported too (but no attribut).

0 Kudos