<legend id='sSsf3'><style id='sSsf3'><dir id='sSsf3'><q id='sSsf3'></q></dir></style></legend>

<tfoot id='sSsf3'></tfoot>
  • <i id='sSsf3'><tr id='sSsf3'><dt id='sSsf3'><q id='sSsf3'><span id='sSsf3'><b id='sSsf3'><form id='sSsf3'><ins id='sSsf3'></ins><ul id='sSsf3'></ul><sub id='sSsf3'></sub></form><legend id='sSsf3'></legend><bdo id='sSsf3'><pre id='sSsf3'><center id='sSsf3'></center></pre></bdo></b><th id='sSsf3'></th></span></q></dt></tr></i><div id='sSsf3'><tfoot id='sSsf3'></tfoot><dl id='sSsf3'><fieldset id='sSsf3'></fieldset></dl></div>

          <bdo id='sSsf3'></bdo><ul id='sSsf3'></ul>
      1. <small id='sSsf3'></small><noframes id='sSsf3'>

      2. 在 Python 中从 csv 创建 kml

        Create kml from csv in Python(在 Python 中从 csv 创建 kml)
          • <bdo id='nSfuv'></bdo><ul id='nSfuv'></ul>

          • <i id='nSfuv'><tr id='nSfuv'><dt id='nSfuv'><q id='nSfuv'><span id='nSfuv'><b id='nSfuv'><form id='nSfuv'><ins id='nSfuv'></ins><ul id='nSfuv'></ul><sub id='nSfuv'></sub></form><legend id='nSfuv'></legend><bdo id='nSfuv'><pre id='nSfuv'><center id='nSfuv'></center></pre></bdo></b><th id='nSfuv'></th></span></q></dt></tr></i><div id='nSfuv'><tfoot id='nSfuv'></tfoot><dl id='nSfuv'><fieldset id='nSfuv'></fieldset></dl></div>

                <tfoot id='nSfuv'></tfoot>

                  <tbody id='nSfuv'></tbody>
              • <small id='nSfuv'></small><noframes id='nSfuv'>

                  <legend id='nSfuv'><style id='nSfuv'><dir id='nSfuv'><q id='nSfuv'></q></dir></style></legend>
                  本文介绍了在 Python 中从 csv 创建 kml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我是 Python 新手.我正在处理 gps 文件.我需要将包含所有 gps 数据的 CSV 文件转换为 kml 文件.下面是我正在使用的python中的代码:

                  I am new to Python. I am working on gps files. I need to convert a CSV file having all the gps data to kml file. Below is the code in python I am using :

                  import csv
                  #Input the file name.
                  fname = raw_input("Enter file name WITHOUT extension: ")
                  data = csv.reader(open(fname + '.csv'), delimiter = ',')
                  #Skip the 1st header row.
                  data.next()
                  #Open the file to be written.
                  f = open('csv2kml.kml', 'w')
                  
                  #Writing the kml file.
                  f.write("<?xml version='1.0' encoding='UTF-8'?>
                  ")
                  f.write("<kml xmlns='http://earth.google.com/kml/2.1'>
                  ")
                  f.write("<Document>
                  ")
                  f.write("   <name>" + fname + '.kml' +"</name>
                  ")
                  for row in data:
                      f.write("   <Placemark>
                  ")
                      f.write("       <name>" + str(row[1]) + "</name>
                  ")
                      f.write("       <description>" + str(row[0]) + "</description>
                  ")
                      f.write("       <Point>
                  ")
                      f.write("           <coordinates>" + str(row[3]) + "," + str(row[2]) + "," + str(row[4]) + "</coordinates>
                  ")
                      f.write("       </Point>
                  ")
                      f.write("   </Placemark>
                  ")
                  f.write("</Document>
                  ")
                  f.write("</kml>
                  ")
                  print "File Created. "
                  print "Press ENTER to exit. "
                  raw_input()
                  

                  我使用的 csv 文件可在此处获得:dip12Sep11newEdited.csv生成的 kml 文件可在此处获得:csv2kml.kml但是没有正确创建 kml 文件.显然,在 csv 中的某些行之后,代码无法生成更多地标.它无法迭代.您可以通过滚动到生成的 kml 文件的最后部分来查看.

                  The csv file I am using is available here : dip12Sep11newEdited.csv The kml file generated is available here : csv2kml.kml But the kml file is not getting created correctly. Apparently after some rows in the csv the code is not able to generate more Placemarks. Its not able to iterate. You can see that by scrolling to the last part of the kml file generated.

                  谁能帮我找出代码中的错误,因为对于一些较小的 csv 文件,它可以正常工作并完全创建 kml 文件.

                  Can anyone help me finding out the error in the code, because for some smaller csv files it worked correctly and created kml files fully.

                  谢谢.

                  推荐答案

                  你没有回答上面的问题,但我猜错误是你没有关闭你的输出文件(这会刷新你的输出).

                  You didn't answer the query above, but my guess is that the error is that you're not closing your output file (which would flush your output).

                  f.close()
                  

                  这篇关于在 Python 中从 csv 创建 kml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                  Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                  python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                  Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                  How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                  Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)
                    <tbody id='iygBo'></tbody>

                  <i id='iygBo'><tr id='iygBo'><dt id='iygBo'><q id='iygBo'><span id='iygBo'><b id='iygBo'><form id='iygBo'><ins id='iygBo'></ins><ul id='iygBo'></ul><sub id='iygBo'></sub></form><legend id='iygBo'></legend><bdo id='iygBo'><pre id='iygBo'><center id='iygBo'></center></pre></bdo></b><th id='iygBo'></th></span></q></dt></tr></i><div id='iygBo'><tfoot id='iygBo'></tfoot><dl id='iygBo'><fieldset id='iygBo'></fieldset></dl></div>

                      • <small id='iygBo'></small><noframes id='iygBo'>

                            <bdo id='iygBo'></bdo><ul id='iygBo'></ul>
                          • <tfoot id='iygBo'></tfoot>
                          • <legend id='iygBo'><style id='iygBo'><dir id='iygBo'><q id='iygBo'></q></dir></style></legend>