python(27) Folium (지도 시각화 도구)

hyukstory 혁스토리·2020년 9월 4일
0

python

목록 보기
33/35

지도 시각화

import folium


#html 로 저장하고 크롬으로 실행
map1 = folium.Map(location=[45.5236, -122.6750])
map1.save("C:/Users/student/Desktop/python/P_4week/map1.html")
map1 

#zoom 해보기
map2 = folium.Map(location=[45.5236, -122.6750], zoom_start=13)
map2.save("C:/Users/student/Desktop/python/P_4week/map2.html")
map2


#tiles 옵션
map3 = folium.Map(location=[45.5236, -122.6750], tiles='map3 Toner', 
                    zoom_start=13)
map3.save("C:/Users/student/Desktop/python/P_4week/map3.html")
map3


map4 = folium.Map(location=[45.5236, -122.6750], 
                    tiles='map4 Terrain', zoom_start=13)
map4.save("C:/Users/student/Desktop/python/P_4week/map4.html")
map4



# Marker 
## popup = 아이콘에 마우스 갖다댔을때 뜨는 창
## folium.Icon = 마커 아이콘
map5 = folium.Map(location=[45.372, -121.6972], zoom_start=12,
                   tiles='Stamen Terrain')
folium.Marker([45.3288, -121.6625], popup='Mt. Hood Meadows',     
              icon=folium.Icon(icon='cloud')).add_to(map5)
folium.Marker([45.3311, -121.7113], popup='Timberline Lodge', 
              icon=folium.Icon(icon='cloud')).add_to(map5)
map5.save(("C:/Users/student/Desktop/python/P_4week/map5.html"))
map5



map6 = folium.Map(location=[45.372, -121.6972], zoom_start=12, 
                   tiles='Stamen Terrain')
folium.Marker([45.3288, -121.6625], popup='Mt. Hood Meadows', 
              icon=folium.Icon(icon='cloud')).add_to(map6)
folium.Marker([45.3311, -121.7113], popup='Timberline Lodge', 
              icon=folium.Icon(color='green')).add_to(map6)
folium.Marker([45.3300, -121.6823], popup='Some Other Location', 
              icon=folium.Icon(color='red',icon='info-sign')).add_to(map6)
map6.save(("C:/Users/student/Desktop/python/P_4week/map6.html"))
map6



# CircleMarker
map7 = folium.Map(location=[45.5236, -122.6750], tiles='Stamen Toner', 
                   zoom_start=13)
folium.Marker([45.5244, -122.6699], popup='The Waterfront' ).add_to(map7)
folium.CircleMarker([45.5215, -122.6261], radius=50, 
                    popup='Laurelhurst Park', color='#3186cc', 
                    fill_color='#3186cc', ).add_to(map7)
map7.save(("C:/Users/student/Desktop/python/P_4week/map7.html"))
map7





# RegularpolygonMarker : 다각형
map8 = folium.Map(location=[45.5236, -122.6750], zoom_start=13)
folium.RegularPolygonMarker([45.5012, -122.6655], 
                            popup='Ross Island Bridge', fill_color='#132b5e', 
                            number_of_sides=3, radius=10).add_to(map8)
folium.RegularPolygonMarker([45.5132, -122.6708], 
                            popup='Hawthorne Bridge', fill_color='#45647d', 
                            number_of_sides=4, radius=10).add_to(map8)
folium.RegularPolygonMarker([45.5275, -122.6692], 
                            popup='Steel Bridge', fill_color='#769d96', 
                            number_of_sides=6, radius=10).add_to(map8)
folium.RegularPolygonMarker([45.5318, -122.6745], 
                            popup='Broadway Bridge', fill_color='#769d96', 
                            number_of_sides=8, radius=10).add_to(map8)
map8.save(("C:/Users/student/Desktop/python/P_4week/map8.html"))
map8





# 미국의 주별 실업률 데이터로 연습
import folium
import pandas as pd
state_unemployment = 'C:/Users/student/Desktop/python/P_4week/02.folium_US_Unemployment_Oct2012.csv'

state_data = pd.read_csv(state_unemployment)
state_data.head()


#json data 에 담아져있는 경계선 좌표를 이용해 경계선있는 지도 그려보기
state_geo = 'C:/Users/student/Desktop/python/P_4week/02.folium_us-states.json'
map9 = folium.Map(location=[40, -98], zoom_start=4)
map9.choropleth(geo_data=state_geo, data=state_data,
             columns=['State', 'Unemployment'],
             key_on='feature.id',
             fill_color='YlGn',
             legend_name='Unemployment Rate (%)')
map9.save("C:/Users/student/Desktop/python/P_4week/map9.html")
map9




profile
문돌이의 고군분투 개발 공부

0개의 댓글