import pandas as pd
import simplekml
url = "https://docs.google.com/spreadsheets/d/e/2PACX-1vRDgDbpuBUvGcK7TJKiwMSIfs5yi95qmERjZ_iXHMWSRDlarjwUoDVdvpXOB8a2zpnwpq4Vj9VBHJcf/pub?gid=592572816&single=true&output=csv"
df = pd.read_csv(url, index_col=0).fillna("")
df
kml = simplekml.Kml(name="Ehime")
path = kml.addfile("rakuten.png")
normal = simplekml.Style()
normal.iconstyle.scale = 1.1
normal.iconstyle.colormode = None
normal.iconstyle.heading = None
normal.iconstyle.icon.href = path
normal.iconstyle.hotspot = simplekml.HotSpot(
x="16", xunits="pixels", y="16", yunits="insetPixels"
)
normal.labelstyle.scale = 0
normal.labelstyle.colormode = None
highlight = simplekml.Style()
highlight.iconstyle.scale = 1.1
highlight.iconstyle.colormode = None
highlight.iconstyle.heading = None
highlight.iconstyle.icon.href = path
highlight.iconstyle.hotspot = simplekml.HotSpot(
x="16", xunits="pixels", y="16", yunits="insetPixels"
)
highlight.labelstyle.scale = 1.1
highlight.labelstyle.colormode = None
stylemap = simplekml.StyleMap()
stylemap.normalstyle = normal
stylemap.highlightstyle = highlight
kml.document.stylemap = stylemap
fol = kml.newfolder(name="Imabari")
for _, r in df.iterrows():
pnt = fol.newpoint(name=r["場所"])
pnt.coords = [(r["経度"], r["緯度"])]
pnt.stylemap = kml.document.stylemap
ex_data = simplekml.ExtendedData()
for n, v in r.items():
ex_data.newdata(name=str(n), value=str(v))
pnt.extendeddata = ex_data
kml.savekmz("imabari.kmz")