simplekml を使って国連加盟国の国旗をマーカーとして表示するKMLを作成する

simplekml を使って国旗をマーカーとして表示する KML ファイルを作成する の続きです。

前回は 東京の位置に日本の国旗を表示した。

今回は 国連加盟国 の国旗を地図に表示する。

JSON ファイル(国連加盟国の一覧) を読み込んで for ループで処理する。

with open('un_members_capital.json') as f1:
    dic = json.load(f1)
    list_countries = dic['countries']
#

# Placemark
for item in list_countries:
    country = item['country']
    url_country = item['url_country']
    url_flag_icon = item['url_flag_icon']
    lat = item['lat']
    lon = item['lon']
    print(country)

    point = kml.newpoint(name = country)
    point.coords = [(lon, lat)]
    point.style.iconstyle.icon.href = url_flag_icon
    point.description =  FORMAT_DESCRIPTION.format(href=url_country, name=country)

作成した KMLファイルを Google マイマップ にインポートする。

プログラムは GitHub に公開した。

https://github.com/ohwada/World_Countries/tree/main/simplekml/un_member_states

Google Earth

作成した KMLファイルを Google Earth で表示する。

国旗が米粒のように小さく表示される。

画像を横幅20px から px100pxにしてもさほど変らず。