将csv文件转换为KML

时间:2017-11-08 15:48:58

标签: java csv arraylist kml

我正在尝试将我的csv文件转换为kml文件。 我建立了一个收到arraylist的方法。 我不明白为什么我正在获取的kml文件没有在谷歌地球上运行。

这是我的代码:

es = Elasticsearch(
    hosts=[{'host': '***', 'port': ***}],
    http_auth=('***', '***'),
    use_ssl=True
)

count = es.count(index="***", doc_type="***")
print(count)  # {u'count': 244532, u'_shards': {u'successful': 5, u'failed': 0, u'total': 5}}

# Use scroll to ease strain on cluster (don't pull in all results at once)
results = es.search(index="***", doc_type="***", size=1000,
                    scroll="30s")  
scroll_id = results['_scroll_id']
total_size = results['hits']['total']
print(total_size)

# Save all results in list
dump = []

ct = 1
while total_size > 0:

    results = es.scroll(scroll_id=scroll_id, scroll='30s')

    dump += results['hits']['hits']
    scroll_id = results['_scroll_id']
    total_size = len(results['hits']['hits'])  # As long as there are results, keep going ...
    print("Chunk #", ct, ": ", total_size, "\tList size: ", len(dump))
    ct += 1

es.clear_scroll(body={'scroll_id': [scroll_id]})  # Cleanup (otherwise Scroll id remains in ES memory)

该函数获取的csv包含来自不同地方的多重wifi网络。

感谢。

1 个答案:

答案 0 :(得分:0)

KML中的地标集合必须包含在Document或文件夹父元素中,而不是直接位于<kml>元素内。

将最外层元素设为<Document>元素。

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
 <Document>
  <Placemark>...</Placemark>
  <Placemark>...</Placemark>
 </Document>
</kml>