Пример #1
0
def pred_brid():
    global area_value
    global list_area
    global len_area
    global danger

    list_area = None
    len_area = None
    pred_wl = None

    if area_value == 'seoul':
        list_area = list_seoul
        pred_wl = pred_tmp[0]
    elif area_value == 'incheon':
        list_area = list_incheon
        pred_wl = pred_tmp[1]
    elif area_value == 'gyeonggi':
        list_area = list_gyeonggi
        pred_wl = pred_tmp[2]
    print(pred_wl)
    print(list_area)

    if list_area != None:
        len_area = len(list_area)

    #############################################################################

    start_coords = (37.5642135, 127.0016985)
    m = folium.Map(location=start_coords, zoom_start=9, width='100%')

    #############################################################################

    with open('sudo_geo.json', mode='rt', encoding='utf-8') as f:
        geo_sudo = json.loads(f.read())

    folium.GeoJson(geo_sudo, name='sudo_geo').add_to(m)

    #############################################################################

    folium_map = MarkerCluster().add_to(m)

    danger.clear()
    if list_area != None:
        for i in range(len(list_area)):
            text = """\
                <table style=width:100%>
                    <tr>
                        <th>교량 이름</th> <th>교량 높이</th> <th>예측 수위</th>
                    </tr>
                    <tr>
                        <td>{0}</td> <td>&nbsp;&nbsp;&nbsp;{1:.2f}m</td> <td>&nbsp;&nbsp;&nbsp;{2:.2f}m</td>
                    </tr>
                </table> """.format(str(list_area[i].bridge_name),
                                    list_area[i].bridge_height * 0.01,
                                    pred_wl[i] * 0.01)
            pp_text = folium.IFrame(text, width=350, height=80)
            pp = folium.Popup(pp_text, max_width=400)
            if list_area[i].bridge_height * 0.3 > pred_wl[i]:
                print('blue: ')
                print(pred_wl[i], list_area[i].bridge_height * 0.3)
                ic = folium.Icon(color='blue', icon='info-sign')
                danger.append('안전')
            elif list_area[i].bridge_height * 0.6 > pred_wl[i]:
                print('yellow: ')
                print(pred_wl[i], list_area[i].bridge_height * 0.6)
                ic = folium.Icon(color='orange', icon='info-sign')
                danger.append('주의')
            else:
                print('red: ')
                print(pred_wl[i])
                ic = folium.Icon(color='red', icon='info-sign')
                danger.append('위험')
            folium.Marker(
                location=[list_area[i].latitude, list_area[i].longitude],
                popup=pp,
                icon=ic,
            ).add_to(folium_map)

    folium_map.save('templates/map_{0}.html'.format(area_value))
Пример #2
0
import folium
import pandas as pd
from folium.plugins import MarkerCluster
from geopy.geocoders import Nominatim

data = pd.read_csv("kjg-mitglieder.csv", sep=";")

geolocator = Nominatim(timeout=None)
location_list = []

for i in range(data.__len__()):
    location = geolocator.geocode(data['plz'][i])
    location_list.append((location.latitude, location.longitude))

folium_map = folium.Map(location=[50.144, 8.902],
                        zoom_start=9.5,
                        tiles="CartoDB positron")

marker_cluster = MarkerCluster().add_to(folium_map)

for point in range(0, data.__len__()):
    folium.Marker(location_list[point]).add_to(marker_cluster)

marker_cluster.save("kjg_dv_fulda_locations.html")
Пример #3
0
    # Create custom marker icon | causes size increase of output html file 
    #meteorite_icon = folium.features.CustomIcon('Assets/meteorite.png', icon_size=(80,80))
    
    html = f"""
    <table border="1">
        <tr>
            <th> ID </th>
            <th> Name </th>
            <th> Year </th>
            <th> Mass(g) </th>
            <th> Class </th>
            <th> Latitude </th>
            <th> Longitude </th>
        </tr>
        <tr>
            <td> {ID} </td> 
            <td> {name} </td>
            <td> {year} </td>
            <td> {mass} </td>
            <td> {rec_class} </td>
            <td> {latitude} </td>
            <td> {longitude} </td>
        </tr>
    </table>"""
    iframe = folium.IFrame(html=html, width=375, height=125)
    popup = folium.Popup(iframe, max_width=375)

    folium.Marker(location=[latitude, longitude], popup=popup).add_to(cluster_map)

cluster_map.save("meteorite_cluster_map.html")