I have kmz's that I would like to overlay in Arcmap for comparison to our data but I don't want to convert it.
well...
<SPAN class="string token">""" Script: kmz_kml.py Author: <A class="jive-link-email-small" href="mailto:Dan.Patterson@carleton.ca" rel="nofollow noopener noreferrer" target="_blank">Dan.Patterson@carleton.ca</A> References: many Purpose: convert kmz to kml base script """</SPAN> <SPAN class="keyword token">import</SPAN> zipfile <SPAN class="keyword token">from</SPAN> xml<SPAN class="punctuation token">.</SPAN>dom <SPAN class="keyword token">import</SPAN> minidom <SPAN class="keyword token">def</SPAN> <SPAN class="token function">kmz_to_kml</SPAN><SPAN class="punctuation token">(</SPAN>fname<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"""save kmz to kml"""</SPAN> zf <SPAN class="operator token">=</SPAN> zipfile<SPAN class="punctuation token">.</SPAN>ZipFile<SPAN class="punctuation token">(</SPAN>fname<SPAN class="punctuation token">,</SPAN><SPAN class="string token">'r'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> fn <SPAN class="keyword token">in</SPAN> zf<SPAN class="punctuation token">.</SPAN>namelist<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">if</SPAN> fn<SPAN class="punctuation token">.</SPAN>endswith<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'.kml'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> content <SPAN class="operator token">=</SPAN> zf<SPAN class="punctuation token">.</SPAN>read<SPAN class="punctuation token">(</SPAN>fn<SPAN class="punctuation token">)</SPAN> xmldoc <SPAN class="operator token">=</SPAN> minidom<SPAN class="punctuation token">.</SPAN>parseString<SPAN class="punctuation token">(</SPAN>content<SPAN class="punctuation token">)</SPAN> out_name <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>fname<SPAN class="punctuation token">.</SPAN>replace<SPAN class="punctuation token">(</SPAN><SPAN class="string token">".kmz"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">".kml"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>replace<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"\\"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"/"</SPAN><SPAN class="punctuation token">)</SPAN> out <SPAN class="operator token">=</SPAN> open<SPAN class="punctuation token">(</SPAN>out_name<SPAN class="punctuation token">,</SPAN><SPAN class="string token">'w'</SPAN><SPAN class="punctuation token">)</SPAN> out<SPAN class="punctuation token">.</SPAN>writelines<SPAN class="punctuation token">(</SPAN>xmldoc<SPAN class="punctuation token">.</SPAN>toxml<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> out<SPAN class="punctuation token">.</SPAN>close<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"no kml file"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> __name__ <SPAN class="operator token">==</SPAN> <SPAN class="string token">"__main__"</SPAN><SPAN class="punctuation token">:</SPAN> fname <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"Your_folder_here\GIS_central.kmz"</SPAN> kmz_to_kml<SPAN class="punctuation token">(</SPAN>fname<SPAN class="punctuation token">)</SPAN> <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
found it. which could obviously be cleverly modified for batch production
kmz files are zipped kml files ... some backgrounders that are useful
Can I convert a kmz file to kml? - Geographic Information Systems Stack Exchange
provides some help and with the aid of python modules:
one can even process things directly, for example
Calculate distance from .kmz files « Python recipes « ActiveState Code
And there are many other examples out there.
You might be right, Chris. The supported formats lists "OpenGIS KML Encoding Standard" although I don't know if that includes all KML, or any KMZ.
I think you can natively with ArcGIS Data Interoperability (ArcGIS Data Interoperability | Overview).
David,
Like Darren said, you will need to convert it.
Use this tool:
KML To Layer—Help | ArcGIS for Desktop
Make edits, then use the opposite tool to change it back:
Layer To KML—Help | ArcGIS for Desktop
There is no way to view KMZ in ArcMap without converting it.
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.