OSMNX 和 Shapely 多边形切割

问题描述

我想将多边形溢出到由许多小正方形/形状组成的编号网格中,但结果是将多边形分成四个部分,而不是代码有什么问题我已经尝试解决了几个小时但不确定该怎么做:

 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 polygon
 city=ox.geocode_to_gdf("Paris,France")

 geometry = city['geometry'].iloc[0]
 geometry_split = 
 ox.utils_geo._quadrat_cut_geometry(geometry,quadrat_width = 750)

 polylist = [p for p in geometry_split]

 west,south,east,north = city.unary_union.bounds
 fig,ax = plt.subplots(figsize=(30,30))
 for polygon,n in zip(geometry_split,np.arange(len(polylist))):
 p = polygon.representative_point().coords[:][0]
 patch = 
 polygonPatch(polygon,ec='#100000',alpha=0.5,zorder=2)
 ax.add_patch(patch)
 plt.annotate(text=n,xy=p,horizontalalignment='center',size=15)
 ax.set_xlim(west,east)
 ax.set_ylim(south,north)
 ax.axis('off')
 plt.show()

结果如下:

enter image description here

解决方法

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

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

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