Pydeck, Python 데이터 시각화. Carto 맵의 열 레이어.
Feb 18 2023
Python 및 pandas 라이브러리를 사용하여 deck.gl 지리 데이터 시각화 기능을 탐색할 것입니다.
Python 및 pandas 라이브러리를 사용하여 deck.gl 지리 데이터 시각화 기능을 탐색할 것입니다 . Deck.gl 은 대규모 데이터세트를 위한 WebGL 기반 시각화 프레임워크이고 pydeck은 Python용 대규모 공간 렌더링(deck.gl에서 제공)입니다.
이 프로젝트에서는 전산 문서를 만들고 공유하기 위한 원본 웹 애플리케이션인 Jupyter Notebook을 사용하고 있습니다 . 간단하고 능률적인 문서 중심 환경을 제공합니다.
이 프로젝트의 핵심 Python 라이브러리는 pydeck입니다. 기본적으로 pydeck 0.6은 Carto를 통해 베이스맵 타일을 제공합니다. Mapbox에 등록하여 선택적으로 Mapbox API 키를 사용할 수 있습니다. 하지만 이 프로젝트에는 Carto 맵만으로도 충분합니다.
pip를 통해 pydeck을 가져오겠습니다.
pip install pydeck
- 작업에 필요한 필수 Python 라이브러리인 pandas, pydeck, os 및 선택적으로 matplotlib.pyplot (나중에 이 게시물을 개발할 수 있음)을 가져오는 것으로 시작합니다.
import pandas as pd
import pydeck as pdk
from pydeck.types import String
import matplotlib.pyplot as plt
import os
os.listdir() ## checking the current file composition of the folder
df = pd.read_excel('stores.xlsx') ## reading .xlsx file to Pandas DataFrame
df.set_index('Location Name') ## setting indexing to store's name
df.columns
# output
# Index(['Location Name', 'Address line 1', 'Address line 2', 'Address line 3',
# 'City Name', 'Latitude', 'Longitude', 'Lat', 'Long', 'Postal Code',
# 'Results'],
# dtype='object')
df2 = df[['Location Name', 'City Name', 'Latitude', 'Longitude', 'Lat', 'Long', 'Postal Code', 'Results']]
df2
df2["Long"] = df2["Long"].astype(float)
df2["Lat"] = df2["Lat"].astype(float)
df2
layer = pdk.Layer(
'ColumnLayer',
df2,
get_position=['Long', 'Lat'],
get_elevation=["Results"],
auto_highlight=True,
elevation_scale=5,
pickable=True,
extruded=True,
get_radius=100,
get_fill_color=["Results * 10", "Results", "Results * 40", 220],
coverage=1
)
# Set the viewport location
view_state = pdk.ViewState(
longitude=25.336900,
latitude=54.734235,
zoom=2,
min_zoom=5,
max_zoom=15,
pitch=40.5,
bearing=-27.36)
r = pdk.Deck(layers=[layer], initial_view_state=view_state)
r.to_html('stores.html')

![연결된 목록이란 무엇입니까? [1 부]](https://post.nghiatu.com/assets/images/m/max/724/1*Xokk6XOjWyIGCBujkJsCzQ.jpeg)



































