osmnx 和 geopandas 可视化城市地图

问题描述

下面的代码显示一个城市根据坐标被分割成更小的方块:

import numpy as np                                                                 
import pandas as pd
import matplotlib.pyplot as plt 
import geopandas as gpd
import osmnx as ox
from descartes import polygonPatch
from shapely.geometry import Point,Linestring,polygon,Multipolygon

ox.config(use_cache=True,log_console=True)
city = ox.geocode_to_gdf("Yerevan,Armenia")
print(city.crs)


state = ox.projection.project_gdf(city) #to convert from longlat system to 
 metric system 
 print(city)
 ax = ox.project_gdf(city).plot(fc='blue',ec='none')
 _ = ax.axis('on')

city.to_file('./desktop/yerevan')
 
geometry = city['geometry'].iloc[0]
 print(type(geometry))

 geometry = ox.utils_geo._quadrat_cut_geometry(geometry,2000)
 len(geometry)

 polylist = [p for p in geometry]

  # plot city
     west,south,east,north = city.unary_union.bounds

   fig,ax = plt.subplots(figsize=(40,40))
for polygon,n in zip(geometry,np.arange(len(polylist))):
p = polygon.representative_point().coords[:][0]
patch = polygonPatch(polygon,fc='#ffffff',ec='#000000',alpha=0.5,zorder=2)
ax.add_patch(patch)
plt.annotate(s=n,xy=p,horizontalalignment='center',size=15)

ax.set_xlim(west,east)
ax.set_ylim(south,north)
ax.axis('off')
plt.show()

我不知道我做错了什么,因为我得到了这张图片

I don't know what Im doing incorrect since I get this image:

而不是它假设的:

Instead of this which it suppose to be:

非常感谢您的帮助

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)