如何使用pyrosm加载地图?

问题描述 投票:0回答:1

嗯,我想做的是打开地图,并使用两个地理参考点,尝试计算它们之间通过高速公路的距离。

使用([https://pyrosm.readthedocs.io/en/latest/basics.html](pyrosm示例))我创建了以下代码:

from pyrosm import OSM, get_data
import osmnx as ox
import time

osm = OSM(get_data("sudeste", directory="/home/brunob/mapas"))

buildings = osm.get_buildings()
buildings.plot()

drive_net = osm.get_network(network_type="driving")
drive_net.plot()

我收到了这个错误:

 Traceback (most recent call last):
 File "/home/brunob/códigos/plotando_mapa.py", line 18, in <module>
 drive_net = osm.get_network(network_type="driving")
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/home/brunob/.local/lib/python3.11/site-packages/pyrosm/pyrosm.py", line 249, in get_network
 edges, node_gdf = get_network_data(
                       ^^^^^^^^^^^^^^^^^
File "/home/brunob/.local/lib/python3.11/site-packages/pyrosm/networks.py", line 18, in get_network_data
nodes, ways, relation_ways, relations = get_osm_data(
                                            ^^^^^^^^^^^^^
File "pyrosm/data_manager.pyx", line 175, in pyrosm.data_manager.get_osm_data
File "pyrosm/data_manager.pyx", line 176, in pyrosm.data_manager.get_osm_data
File "pyrosm/data_manager.pyx", line 172, in pyrosm.data_manager._get_osm_data
File "pyrosm/data_manager.pyx", line 130, in pyrosm.data_manager.get_osm_ways_and_relations
File "pyrosm/data_manager.pyx", line 95, in pyrosm.data_manager.get_way_arrays
File "pyrosm/_arrays.pyx", line 93, in pyrosm._arrays.convert_to_arrays_and_drop_empty
File "pyrosm/_arrays.pyx", line 79, in pyrosm._arrays.convert_to_arrays_and_drop_empty
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

我的错误是什么?

感谢您的帮助

python gis openstreetmap pyosmium
1个回答
0
投票

我仅使用 osmnx 解决问题

import osmnx as ox
import networkx as nx
import os
import time

def carregar_grafo(lugar, caminho_arquivo):
    if os.path.isfile(caminho_arquivo):
        return ox.load_graphml(caminho_arquivo)
    else:
        G = ox.graph_from_place(lugar, network_type="drive_service")
        ox.save_graphml(G, caminho_arquivo)
        return G

tempo_inicial = time.time()

localizacao = 'estado de São Paulo, Região Sudeste, Brasil'

arquivo = !pwd
arquivo = str(arquivo[0]) + '/mapas/estado_sp.graphml'
G = carregar_grafo(localizacao, arquivo)

tempo_final = time.time()

print("--- %s segundos ---" % (tempo_final - tempo_inicial))


# impute missing edge speeds and add travel times
G = ox.add_edge_speeds(G)
G = ox.add_edge_travel_times(G)

对于地址,我使用开放街道地图网站,寻找 ox.graph_from_place 函数的正确单词。

就是这样,pyrosm 围脖还没有更新(直到现在)。

© www.soinside.com 2019 - 2024. All rights reserved.