![](/img/trans.png)
[英]If this possible to convert geoJson to KML file and export it in react native?
[英]Export Geojson file automatically in folium Draw plugin?
我最近被介紹到folium ,我需要訪問導出的 Geojson 文件。 我為我的項目找到了一個簡短的代碼。
import folium
from folium.plugins import Draw
m = folium.Map()
draw = Draw(
export=True,
filename='data.geojson',
position='topleft',
draw_options={'polyline': False,
'circlemarker': False,
'polygon': False,
'marker': False},
edit_options={'poly': {'allowIntersection': False}})
draw.add_to(m)
m
這很簡單。
但我想知道是否有人知道是否有任何方法可以在繪制每個多邊形后自動保存 Geojson 文件而無需單擊導出按鈕; 因為我需要實時訪問屬性。
提前致謝。
您有 2 個選項可以自動保存 geojson。
..
import folium
from folium.plugins import Draw
m = folium.Map()
draw = Draw(
export=True,
filename='data.geojson',
position='topleft',
draw_options={'polyline': False,
'circlemarker': False,
'polygon': False,
'marker': False},
edit_options={'poly': {'allowIntersection': False}})
draw.add_to(m)
#Refresh the map html
m.get_root().render()
#modify script tag contents to include layer download on 'layeradd' event
script =f"""
{m.get_name()}.on('layeradd', function(e) {{
layer = e.layer;
if (layer.toGeoJSON()) {{
document.getElementById('export').click()}} }})"""
e = folium.Element(script)
html = m.get_root()
html.script.add_child(e)
m
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.