我正在尝试将点的集合绘制到华盛顿州金县的图形上。
我可以使用以下代码显示图形:
fig, ax = plt.subplots(figsize = (15,15))
kings_county.plot(ax=ax)
这给了我图形。然后,我从加载的 csv 的纬度/经度中读取点。
df = pd.read_csv('kc_house_data_train.csv')
crs = {'init': 'epsg:4326'}
这会将所有点放入一个新的数据框中
geometry = [Point(x,y) for x,y in zip(df.lat,df.long)]
geo_df = gpd.GeoDataFrame(df, # specifify your dataframe
crs = crs, # this is your coordinate system
geometry = geometry) # specify the geometry list we created
但是,当我这样做时
fig, ax = plt.subplots(figsize = (40,40))
kings_county.plot(ax=ax, alpha = 0.4, color = 'grey', aspect = 'auto')
geo_df[geo_df.price >= 750000].plot(ax = ax , markersize = 20, color = 'blue',marker = 'o',label = 'pricey')
geo_df[geo_df.price < 750000].plot(ax = ax , markersize = 20, color = 'blue',marker = 'o',label = 'pricey')
plt.legend()
它只是返回一个错误:ValueError:“box_aspect”和“fig_aspect”必须为正不知道为什么加载图形可以工作,但添加的点会使它中断。
如果可以的话,只是寻求对此的理解和修复。谢谢