<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Convert all .lyr inside .mxd into .kmz in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/convert-all-lyr-inside-mxd-into-kmz/m-p/699833#M54228</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm looking for a way to convert all .lyr contained in a .mxd file into .kmz.&lt;/P&gt;&lt;P&gt;I wrote this script that is supposed to be simple but still, it doesn't seem to work.&lt;/P&gt;&lt;P&gt;The script is creating .kmz but these .kmz don't look like what they should. If I open them in ArcMap, I receive an error message saying "Warning, inconsistent extent". I can see some strange points though, but that seem aligned while they shouldn't be. If I open the kmz with Google Earth, it doesn't display anything, I just end up in the middle of the ocean...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;EM&gt;import arcpy&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.env.workspace =&amp;nbsp;path&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;mxd = arcpy.mapping.MapDocument(path)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;AllLayers=arcpy.mapping.ListLayers(mxd)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;for layer in AllLayers:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;outputkmz = layer.name[:-4]+".kmz"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.LayerToKML_conversion(layer,outputkmz)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Additionnal information:&lt;/P&gt;&lt;P&gt;- If the mxd contains only one layer in the ToC, it's working. As soon as there are more than 1, it's not working anymore&lt;/P&gt;&lt;P&gt;- I don't think it's a problem of Coordinates System&lt;/P&gt;&lt;P&gt;- I tried to play with the output extent in LayerToKML but didn't change much&lt;/P&gt;&lt;P&gt;- When I convert the .lyr manually in ArcMap with the toolbox, it's working, so the problem shouldn't come from the .lyr&lt;/P&gt;&lt;P&gt;- I noticed that when I convert manually, it's also creating a metadata file while it doesn't when I run the script. I don't know if that might help?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I feel like I tried everything and I really don't get why the script isn't working properly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 23 Jan 2018 18:52:17 GMT</pubDate>
    <dc:creator>CélineRoman1</dc:creator>
    <dc:date>2018-01-23T18:52:17Z</dc:date>
    <item>
      <title>Convert all .lyr inside .mxd into .kmz</title>
      <link>https://community.esri.com/t5/python-questions/convert-all-lyr-inside-mxd-into-kmz/m-p/699833#M54228</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm looking for a way to convert all .lyr contained in a .mxd file into .kmz.&lt;/P&gt;&lt;P&gt;I wrote this script that is supposed to be simple but still, it doesn't seem to work.&lt;/P&gt;&lt;P&gt;The script is creating .kmz but these .kmz don't look like what they should. If I open them in ArcMap, I receive an error message saying "Warning, inconsistent extent". I can see some strange points though, but that seem aligned while they shouldn't be. If I open the kmz with Google Earth, it doesn't display anything, I just end up in the middle of the ocean...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;EM&gt;import arcpy&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.env.workspace =&amp;nbsp;path&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;mxd = arcpy.mapping.MapDocument(path)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;AllLayers=arcpy.mapping.ListLayers(mxd)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;for layer in AllLayers:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;outputkmz = layer.name[:-4]+".kmz"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.LayerToKML_conversion(layer,outputkmz)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Additionnal information:&lt;/P&gt;&lt;P&gt;- If the mxd contains only one layer in the ToC, it's working. As soon as there are more than 1, it's not working anymore&lt;/P&gt;&lt;P&gt;- I don't think it's a problem of Coordinates System&lt;/P&gt;&lt;P&gt;- I tried to play with the output extent in LayerToKML but didn't change much&lt;/P&gt;&lt;P&gt;- When I convert the .lyr manually in ArcMap with the toolbox, it's working, so the problem shouldn't come from the .lyr&lt;/P&gt;&lt;P&gt;- I noticed that when I convert manually, it's also creating a metadata file while it doesn't when I run the script. I don't know if that might help?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I feel like I tried everything and I really don't get why the script isn't working properly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jan 2018 18:52:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-all-lyr-inside-mxd-into-kmz/m-p/699833#M54228</guid>
      <dc:creator>CélineRoman1</dc:creator>
      <dc:date>2018-01-23T18:52:17Z</dc:date>
    </item>
  </channel>
</rss>

