[英]Piloting polygons on map and exporting as png
我有一個使用 GeoPandas 讀取的形狀文件,以及我使用 pandas 讀取的經度列表。
這個形狀文件有多個多邊形,並有一個與之關聯的屬性。 例如,假設 state 中的縣和人口是屬性。
現在我想 plot 多邊形,在 Map (如谷歌地圖或開放街道地圖)上,並根據屬性為多邊形着色。
然后我想 plot 來自同一 map 上的 csv 的點(在多邊形的頂部)
接下來我想將地圖導出為圖像(例如:png)
I see a ways to plot points on a map (using plotly), ways to plot polygon using geopandas but have not found a way to plot both the polygons and points on a static map which could be exported as image.
我需要的是,一個 map 導出為 png,多邊形顏色編碼為 CSV 中的屬性和點。
代碼示例
import matplotlib.pyplot as plt
import geopandas as gpd
from cartopy import crs as ccrs
path = geopandas.datasets.get_path('naturalearth_lowres')
df = geopandas.read_file(path)
df.crs={'init': 'epsg:3857'}
fig=plt.figure(figsize=[10,5])
ax = fig.add_axes([0, 0, 1, 1], projection=ccrs.Mercator())
ax.set_title('Zindagi Jhandwa Phir bhi Ghamandwa')
ax.add_geometries(df1['geometry'], ccrs.Mercator())
我得到一個空的 plot。 不知道這里有什么問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.