You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用OSMnx graph_from_bbox提取路网图遇类型错误求助

提取路网图生成距离矩阵时遇到TypeError问题求助

我尝试提取路网图以生成距离矩阵,但不确定是数据问题还是其他原因,希望获得帮助。

原始代码如下:

df = pd.read_csv('mat1.csv')

def clean_coordinate(value):
    try:
        value = str(value).replace(',', '.')
        return float(value)
    except ValueError:
        return None  
df['x'] = df['x'].apply(clean_coordinate)
df['y'] = df['y'].apply(clean_coordinate)

north = df['x'].max()
south = df['x'].min()
east = df['y'].max()
west = df['y'].min()

bbox = [north, south, east, west]

graph = ox.graph_from_bbox(*bbox, network_type='drive')

最初收到警告:FutureWarning: The north, south, east, and westparameters are deprecated and will be removed in the v2.0.0 release. Use thebbox parameter instead. See the OSMnx v2 migration guide: https://github.com/gboeing/osmnx/issues/1123

调整后出现新错误:

TypeError:float()必须是字符串或实数,不能是'NoneType'

我检查变量类型的代码:

print(type(bbox))
print(type(north))
print(type(south))
print(type(east))
print(type(west))

执行结果:

<class 'list'>
<class 'numpy.float64'>
<class 'numpy.float64'>
<class 'numpy.float64'>
<class 'numpy.float64'>

即使将numpy.float64转换为普通float:

north1 = north.item()
south1 = south.item()
east1 = east.item()
west1 = west.item()
bbox = [north1, south1, east1, west1]

仍出现相同错误。请问是转换方法有误,还是存在其他问题?


内容的提问来源于stack exchange,提问作者Etienne Jolivel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 18:04:53