- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想从 osmnx 获取最接近经纬对的节点。
在我下载 osmnx 图形对象后,我想投影它,这样我就可以按照文档中的说明从道路网络中移除死胡同。
我知道我需要投影图形和纬度、经度值,但我实际上不明白以哪种方式投影。
例如,我在我的项目中将 lat long 转换为 xy z,但我怎么知道这与该图所做的投影兼容。欧氏方法似乎没有帮助。
标志 rebuild_graph=True 是否也撤消投影并返回未投影的图形对象?如果是这样,经纬度数据并没有靠得很近,无法解释返回的是同一个节点。
long = [20.83099222975307, 20.83099222975307, 20.831071057075036, 20.831507821410554, 20.831536549206216, 20.831590645309163, 20.831760926274246, 20.831829734056857, 20.832064826897437, 20.83211892318422, 20.832291232174775, 20.832453521327647, 20.832467537620413, 20.832744680362744, 20.83275203624094, 20.832893649116148, 20.832933033903316, 20.83298713048916, 20.833011166881615, 20.833109340046658, 20.83317212468842, 20.83317212468842, 20.83319216485246, 20.833193496936566, 20.833256281615377, 20.833335746832073, 20.833345766925337, 20.83338451522313, 20.83367104311693, 20.83367104311693, 20.83378456515314, 20.833896118665407, 20.833897450746417, 20.83400095279438, 20.83400095279438, 20.834029044642254, 20.83411517063695, 20.83413121469866, 20.834177955710697, 20.8341879758658, 20.83424074081229, 20.83424074081229, 20.83424074081229, 20.83424809681322, 20.834270801294185, 20.834296169936398, 20.834302193862516, 20.834302193862516, 20.83430485802092, 20.83430485802092, 20.83441438425335, 20.834493213575563, 20.834498541888962, 20.83452391055964, 20.834525938270623, 20.83458669580759, 20.83459405183661, 20.83459405183661, 20.834608068255694, 20.834616756364248, 20.83467288126638, 20.834695585806365, 20.834695585806365, 20.834742326972062, 20.83503887769283, 20.835118343769174, 20.83514840444336, 20.83576757270048, 20.836452193850544, 20.83755761485359, 20.83759706037195, 20.837852203156956, 20.83795570768881, 20.838343145143025, 20.838343145143025, 20.839993748127704, 20.84092763462079, 20.84092763462079, 20.84092763462079, 20.84092763462079, 20.84127702640877, 20.84127702640877, 20.84127702640877, 20.841985137270154, 20.843422866598996, 20.84377429407861, 20.84377429407861, 20.84377429407861, 20.84377429407861, 20.84377429407861, 20.84377429407861, 20.84377429407861, 20.84377429407861, 20.84377429407861, 20.84402151726155, 20.84402151726155, 20.84548742851209, 20.84548742851209, 20.85188606916644, 20.85501616058255, 20.856737430326934, 20.859542430698603, 20.8613760173422, 20.86163714950174, 20.863028413707386, 20.863180155858238, 20.863345567971184, 20.863412802449744, 20.863424615681698, 20.863451670631083, 20.863495295022673, 20.86349756245783, 20.86346547505983, 20.86346547505983, 20.86346547505983, 20.863419542480333, 20.863411941442653, 20.86332960137235, 20.862958153765447, 20.86259449784883, 20.862368831055996, 20.862368831055996, 20.86213427281035, 20.86212634419993, 20.86188638794884, 20.861807035358805, 20.861375561408494, 20.860967669982454, 20.858716012450735, 20.858716012450735, 20.858706051455755, 20.85862909256079, 20.85859787704128, 20.85611899992582, 20.85611899992582, 20.853380676295366, 20.84616157108611, 20.845523814987697, 20.844864025170992, 20.842355069052047, 20.841927997139937, 20.841920696524085, 20.83342199581793, 20.829528649520768, 20.824360163540142, 20.82338364296999, 20.82231856837287]
lat = [39.62319155463754, 39.62319155463754, 39.62320295662305, 39.6232970230751, 39.62329987357564, 39.623311275578985, 39.623345481600296, 39.6233625846173, 39.6234110431884, 39.62341959470448, 39.623456651286325, 39.6234908573795, 39.623496558396674, 39.623553568594225, 39.623553568594225, 39.623584924222904, 39.62359347576046, 39.62360202729907, 39.62361057883875, 39.62362768192127, 39.62364193449326, 39.62364193449326, 39.62364763552287, 39.62364763552287, 39.62365903758352, 39.62367614067801, 39.62368184171045, 39.623687542743355, 39.62374740361722, 39.62374740361722, 39.62377590881346, 39.62379586245781, 39.62379586245781, 39.623824367674004, 39.623824367674004, 39.623827218196276, 39.62384432133233, 39.623850022378626, 39.623858573948944, 39.62386427499641, 39.62387282656849, 39.62387282656849, 39.62387282656849, 39.62387567709275, 39.62388137814163, 39.62388422866624, 39.62388422866624, 39.62388422866624, 39.62388422866624, 39.62388422866624, 39.623912733918836, 39.623929837076034, 39.623929837076034, 39.62393553812936, 39.62393553812936, 39.623946940237445, 39.62395264129219, 39.62395264129219, 39.62395549181974, 39.62395549181974, 39.62396974445926, 39.62397544551588, 39.62397544551588, 39.6239839971017, 39.62404955929475, 39.62406666248575, 39.62407236355037, 39.62421203978002, 39.624368819557304, 39.62462821960523, 39.62463962182745, 39.624696632966725, 39.62472228799472, 39.624816356512106, 39.624816356512106, 39.62522398823179, 39.62546628794432, 39.62546628794432, 39.62546628794432, 39.62546628794432, 39.62556035747312, 39.62556035747312, 39.62556035747312, 39.62574564631297, 39.626144731653206, 39.62624450334792, 39.62624450334792, 39.62624450334792, 39.62624450334792, 39.62624450334792, 39.62624450334792, 39.62624450334792, 39.62624450334792, 39.62624450334792, 39.62631576893222, 39.62631576893222, 39.626754766550185, 39.626754766550185, 39.62903531847423, 39.63050061275056, 39.631469890610106, 39.63349401463708, 39.63539845582614, 39.63574057656538, 39.638423432026336, 39.63893378506902, 39.63967223552374, 39.640079954790295, 39.640191151371056, 39.64042494989323, 39.64123469722554, 39.64159395436001, 39.64219557167739, 39.64219557167739, 39.64219557167739, 39.642680290858735, 39.64276297858772, 39.643316133524635, 39.64490719146398, 39.64600213432235, 39.64658953268899, 39.64658953268899, 39.64713986675438, 39.64715697565563, 39.64768735369431, 39.64785559273931, 39.648711051843534, 39.64946101303195, 39.652951433740164, 39.652951433740164, 39.65296284063269, 39.65307120620556, 39.65311398213635, 39.656285178192974, 39.656285178192974, 39.65940518392453, 39.66665246841233, 39.66725430386289, 39.66786755390862, 39.67016657695176, 39.67055165652977, 39.670560213878105, 39.678005508599924, 39.68132905057261, 39.6857112353726, 39.686538632203565, 39.68744878016951]
bounding_box = (20.814945, 20.876184, 39.612716999999996, 39.685287)
# Defining the map boundaries
west, east, north, south = bounding_box[0], bounding_box[1], bounding_box[2], bounding_box[3]
# Downloading the map as a graph object
g = ox.graph_from_bbox(north,
south,
east,
west,
network_type='all', clean_periphery=True)
G_proj = ox.project_graph(g)
g = ox.consolidate_intersections(G_proj,
rebuild_graph=True,
tolerance=20,
dead_ends=False)
route = []
for i in range(len(lat)):
point = (lat[i], long[i])
node = ox.get_nearest_node(g, point)
print(node)
route.append(node)
print(route)
最佳答案
I am aware that i project the graph and the lat, long values need to projected to but i dont actually understand in which way.
只需将您的点投影到与您的图表相同的 CRS。根据 the docs ,OSMnx 将您的图形投影到本地 UTM 区域投影,除非您指定不同的 CRS。只需使用投影图的 CRS 属性将您的纬度/经度点投影到相同点,然后进行欧氏最近节点搜索。
这是一个带注释的最小可重现示例:
import geopandas as gpd
import osmnx as ox
from shapely.geometry import Point
ox.config(use_cache=True, log_console=True)
# create graph, project it, then consolidate intersections
bbox = (39.612717, 39.685287, 20.876184, 20.814945)
G = ox.graph_from_bbox(*bbox, network_type='all')
Gp = ox.project_graph(G)
Gc = ox.consolidate_intersections(Gp, rebuild_graph=True, tolerance=20, dead_ends=False)
# turn lat/lng lists into list of shapely points
lats = [39.6654413, 39.6456468, 39.6175496]
lngs = [20.8586396, 20.8496936, 20.8437053]
points_list = [Point((lng, lat)) for lat, lng in zip(lats, lngs)]
# then turn list into GeoSeries with original CRS set
# i'm just guessing that your original CRS is 4326
points = gpd.GeoSeries(points_list, crs='epsg:4326')
# then project your points to the same CRS as your projected graph
points_proj = points.to_crs(Gp.graph['crs'])
# find nearest node in projected graph to each projected point
method = 'euclidean'
nearest_nodes = [ox.get_nearest_node(Gc, (pt.y, pt.x), method) for pt in points_proj]
print(nearest_nodes) # prints [1334, 777, 37]
Also does the flag rebuild_graph=True undo the projection and return an unprojected graph obejct?
没有。
关于python - 转换 osmnx 投影 map 的经纬度坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63245142/
在使用 osmnx 导入道路时,是否有任何方法可以为基础设施类型指定多个子类别。来自 this question我知道我们可以通过指定 infrastructure='way["highway"~"m
在 osmnx 或 networkx 中是否有任何方法可以根据最大长度分割/重新采样/拆分街道边缘? 我正在根据地址进行最短路径路由,但我的 map 通常没有足够的节点分辨率来将节点放置到离每个地址足
这里是一个相对的新手,所以帮助将不胜感激。我正在使用 OSMnx 中的连接指标对车站区域进行国际分类。我需要从每个站点获得 400 米欧几里德缓冲区内的街道网络。即来自站点的简单缓冲区。 在我看来,获
根据文档,边由三个参数唯一定义:u , v和 k .所以即使 u 和 v 可以是相同的参数 k区分边缘 当我计算两个节点之间的最短路径时,我使用 nx.shortest_path .这为我提供了最短路
我正在使用 OSMnx 来提取道路形状。然而,我发现OSM中的某些方法似乎在OSMnx中仅部分地以几何方式表示。 可以在 overpass turbo 上运行的可重现示例: 以及使用
我正在使用 OSMnx 来提取道路形状。然而,我发现OSM中的某些方法似乎在OSMnx中仅部分地以几何方式表示。 可以在 overpass turbo 上运行的可重现示例: 以及使用
我正在使用 OSMnx 从 OpenStreetMaps 道路网络获取干净交叉路口。交叉点当前位于 (x,y) 坐标,但我想使用经纬度坐标绘制它们。 从 Jupiter 笔记本示例中,OSMnx Ex
我尝试使用custom_filter,它对一些小型道路网有效,但对于像整个悉尼网络这样的大型道路网,它不起作用。在输出文件中,还有一些我不想要的其他高速公路类型。 custom_filter='["h
我知道可以通过 OSMNX python 包提取城市的道路网络。查看详情 https://geoffboeing.com/2016/11/osmnx-python-street-networks/ .
我对 Python 和 OSMnx 都很陌生。我正在尝试弄清楚这个包是如何工作的,我的最终目标是能够从街道列表创建形状文件,我希望这个包能让我更接近这个目标。 不幸的是,我在运行获取单个城市街道网络的
如果我在不同的 map 上绘制每条路线,结果是完美的。但是,我想要的是在单个 map 上绘制多条路线。 我的代码是: import osmnx as ox, networkx as nx, matpl
我还试图显示 OpenStreetMap 巴士站节点 439460636 ( https://www.openstreetmap.org/node/439460636 ) 的信息,它是高速公路的一部分
我有大量位置(纬度、经度)数据(10k 行),我想使用 OSMnx 计算从每个点开始的 10 分钟步行等时线。 (我尝试使用 openrouteservice 但有一些限制)。我试过这个例子:http
osmnx 是一种 Python 工具,可让您从 OpenStreetMap 下载 map 并将其用作 Networkx 图表。例如,我可以使用以下命令获取 LA 的街道 map : osmnx.gr
我正在尝试在 Jupyter 笔记本中的现有 OSMnx 图中添加一个点,如下所示 import osmnx as ox import matplotlib.pyplot as plt G = ox.
我想创建一个国家/地区内的道路 map ,并根据其“高速公路”属性为边缘着色,以便高速公路为黄色,主干道为绿色等... 但是,当遵循 osmnx 示例文件并尝试复制时,我收到以下错误消息:输入: ec
我尝试以下代码: G = ox.graph_from_place('Greater London, UK', network_type='walk') 但它一直给出以下错误: ConnectionEr
使用 OSMnx 生成作为一个组获取的多边形并集的最佳实践是什么?的gdf_from_places() ? 在 gboeing的02-example-osm-to-shapefile.ipynb例如,
我正在使用 OSMNx 绘制最短路径路线,但我无法找到在同一张 map 上绘制多条路线的方法。到目前为止,这是我的代码, route_list = [] for i in range(len(pick
我正在尝试使用 OSMnx 在同一图中绘制多个基础设施网络(例如街道、铁路和建筑物),但并未真正取得成功。 这是我的尝试之一: import osmnx as ox dist = 2000 point
我是一名优秀的程序员,十分优秀!