在 Python 視覺化地理空間資料
Mary van Valkenburg
Data Science Program Manager, Nashville Software School
# Construct a map object for Nashville
nashville = [36.1636,-86.7823]
m = folium.Map(location=nashville, zoom_start=10)
# Create a choropleth using the folium Choropleth class
folium.Choropleth(...)
geo_data - 多邊形來源資料(geojson 檔或 GeoDataFrame)name - 多邊形的幾何欄位名稱(或 geojson 屬性)data - 正規化數值的來源 DataFrame 或 Seriescolumns - 兩欄清單:一欄對應多邊形,一欄為要繪製的值key_on - 用來繫結資料的 GeoJSON 變數(一律以 feature 開頭)fill_color - 多邊形填色(預設為藍色) fill_opacity - 介於 0(透明)到 1(不透明)的填色透明度line_color - 多邊形邊線顏色(預設為黑色)line_opacity - 介於 0(透明)到 1(不透明)的邊線透明度 legend_name - 圖例標題# Center point and map for Nashville
nashville = [36.1636,-86.7823]
m = folium.Map(location=nashville, zoom_start=10)
# Define a choropleth layer for the map
folium.Choropleth(
geo_data=districts_with_counts,
name='geometry',
data=districts_with_counts,
columns=['district', 'school_density'],
key_on='feature.properties.district',
fill_color='YlGn',
fill_opacity=0.75,
line_opacity=0.5,
legend_name='Schools per km squared by School District'
).add_to(m)
folium.LayerControl().add_to_map()
display(m)

在 Python 視覺化地理空間資料