티스토리 뷰
▶folium
folium은 지도 위에 데이터를 표현해 주는 대표적인 파이썬 지도 시각화 라이브러리 입니다.
다음 사이트를 참고해봅시다.
Folium — Folium 0.12.1 documentation
folium builds on the data wrangling strengths of the Python ecosystem and the mapping strengths of the leaflet.js library. Manipulate your data in Python, then visualize it in on a Leaflet map via folium. Concepts folium makes it easy to visualize data tha
python-visualization.github.io
▷ folium 라이브러리 install, import
!pip install folium
import folium
▷위도와 경도, 배율을 이용해서 지도 열기
map_folium = folium.Map(location=[37.511835, 127.038549], zoom_start=17)
map_folium
out::::
+ save() : 작성된 지도 차트를 html 파일로 저장
map_folium.save('./map.html')
▷지도 스타일(Open Street Map(기본값), Stamen Terrain, Stamen Toner) 지정
① Open Street Map(기본값)
map_folium = folium.Map(location=[37.511835, 127.038549], zoom_start17, tiles='Open Street Map')
map_folium
out::::
② Stamen Terrain
map_folium = folium.Map(location=[37.511835, 127.038549], zoom_start=17, tiles='Stamen Terrain')
map_folium
out::::
③ Stamen Toner
map_folium = folium.Map(location=[37.511835, 127.038549], zoom_start=17, tiles='Stamen Toner')
map_folium
out::::
▷지도 위에 Marker 생성
Marker() : location 속성으로 지정한 위치에 마커를 생성
Popup() : 마커를 클릭했을 대 표시할 문자열을 생성
add_to() : 작성된 마커를 지도에 추가
map_folium = folium.Map(location=[37.56652479270633, 126.9779129116262], zoom_start=16)
popup = folium.Popup('서울특별시청', max_width=200)
folium.Marker(location=[37.56652479270633, 126.9779129116262], popup=popup).add_to(map_folium)
popup = folium.Popup('덕수궁', max_width=200)
folium.Marker(location=[37.56585320879458, 126.97514572197248], popup=popup).add_to(map_folium)
popup = folium.Popup('서울지방경찰청', max_width=200)
folium.Marker(location=[37.57504045678939, 126.97195576938117], popup=popup).add_to(map_folium)
popup = folium.Popup('광화문', max_width=200)
folium.Marker(location=[37.57617987638928, 126.97694467807803], popup=popup).add_to(map_folium)
popup = folium.Popup('영풍문고-종로본점', max_width=200)
folium.Marker(location=[37.56999947440024, 126.98228391170936], popup=popup).add_to(map_folium)
map_folium
out::::
▷Marker 스타일 지정 : icon=folium.Icon(color='', icon='')
다음 사이트를 참고해서 여러 스타일을 지정해봅시다.
Components · Bootstrap
Extend form controls by adding text or buttons before, after, or on both sides of any text-based . Use .input-group with an .input-group-addon or .input-group-btn to prepend or append elements to a single .form-control. Textual s only Avoid using elements
getbootstrap.com
map_folium = folium.Map(location=[37.56652479270633, 126.9779129116262], zoom_start=16)
popup = folium.Popup('서울특별시청', max_width=200)
folium.Marker(location=[37.56652479270633, 126.9779129116262], popup=popup, icon=folium.Icon(color='beige', icon='star')).add_to(map_folium)
popup = folium.Popup('덕수궁', max_width=200)
folium.Marker(location=[37.56585320879458, 126.97514572197248], popup=popup, icon=folium.Icon(color='red', icon='ok')).add_to(map_folium)
popup = folium.Popup('서울지방경찰청', max_width=200)
folium.Marker(location=[37.57504045678939, 126.97195576938117], popup=popup, icon=folium.Icon(color='blue', icon='user')).add_to(map_folium)
popup = folium.Popup('광화문', max_width=200)
folium.Marker(location=[37.57617987638928, 126.97694467807803], popup=popup, icon=folium.Icon(color='orange', icon='hand-down')).add_to(map_folium)
popup = folium.Popup('영풍문고-종로본점', max_width=200)
folium.Marker(location=[37.56999947440024, 126.98228391170936], popup=popup, icon=folium.Icon(color='purple', icon='eye-open')).add_to(map_folium)
map_folium
out::::
▷원 모양의 Marker 생성 : CircleMarker()
map_folium = folium.Map(location=[37.56652479270633, 126.9779129116262], zoom_start=16)
popup = folium.Popup('서울특별시청', max_width=200)
folium.CircleMarker(location=[37.56652479270633, 126.9779129116262], popup=popup, radius=100, color='#12A57A', fill_color='#E558A7').add)_to(map_folium)
map_folium
out::::

여기까지 지도 시각화 라이브러리 folium에 대해 알아보았습니다 :)
'빅데이터 인공지능 > 데이터분석' 카테고리의 다른 글
[데이터분석] ⑫ 상권별 업종 밀집 통계 실습 (0) | 2022.07.13 |
---|---|
[데이터분석] ⑩ 워드 클라우드(Word Cloud) (0) | 2022.07.12 |
[데이터분석] ⑨ 형태소 분석 (0) | 2022.07.11 |
[데이터분석] ⑧ 셀레니움(Selenium) (0) | 2022.07.11 |
[데이터분석] ⑦ 스크레이핑(Scraping) (0) | 2022.07.09 |
- Total
- Today
- Yesterday
- 프로젝트 회고
- 파이썬
- 프론트엔드
- 타입스크립트
- 머신러닝
- 리액트 훅
- styled-components
- rtl
- 자바스크립트 기초
- frontend
- CSS
- testing
- react-query
- 리액트
- 딥러닝
- 디프만
- 프론트엔드 공부
- 인프런
- next.js
- 자바
- TypeScript
- 스타일 컴포넌트 styled-components
- 데이터분석
- 프론트엔드 기초
- 자바스크립트
- react
- HTML
- Python
- JSP
- jest
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |