邯郸开发网站有哪些,沈阳祥云医院男科怎么样,北京市建设工程招投标,陕西建设网成绩查询BikeDNA#xff08;七#xff09;外在分析#xff1a;OSM 与参考数据的比较1
该笔记本将提供的参考自行车基础设施数据集与同一区域的 OSM 数据进行所谓的外部质量评估进行比较。 为了运行这部分分析#xff0c;必须有一个参考数据集可用于比较。
该分析基于将参考数据集…BikeDNA七外在分析OSM 与参考数据的比较1
该笔记本将提供的参考自行车基础设施数据集与同一区域的 OSM 数据进行所谓的外部质量评估进行比较。 为了运行这部分分析必须有一个参考数据集可用于比较。
该分析基于将参考数据集与 OSM 进行比较并突出显示它们的不同之处包括自行车基础设施在两个数据集中映射的“程度”以及基础设施“如何”映射从而查明差异 在网络结构中。
所有差异都是针对与 OSM 相关的参考数据计算的以 OSM 数据为基线。 例如网络密度的差异是通过计算参考密度减去 OSM 密度来计算的。 因此正差值大于0表示参考值高出多少 负差值低于 0表示参考值低了多少。 因此如果差异以百分比形式给出则 OSM 值将被视为总值 (100%)。
虽然分析是基于比较但它没有对哪个数据集更好做出先验假设。 对于识别出的差异也是如此BikeDNA 不允许自动得出哪个数据集质量更好的结论而是要求用户解释发现的差异的含义例如不同的特征是否是遗漏错误的结果 或佣金以及哪个数据集更正确。 然而许多低值可能表明参考数据的完整性低于 OSM 数据。
目标是确定的差异可用于评估参考数据集和 OSM 数据集的质量并支持决定应使用哪个数据集进行进一步分析。 Prerequisites Input/Output 外部比较几乎完全基于笔记本 2a 和 2b 的结果并期望使用先前笔记本中使用的文件路径来存储结果和绘图。 笔记本 1a、2a、1b 和 2b 必须成功运行才能使用此笔记本。 应用概念和指标的详细解释可以在内在分析笔记本2a 和 2b中找到。 Familiarity required 为了正确解释一些空间数据质量指标需要对该区域有一定的了解。 # Load libraries, settings and dataimport json
import pickle
import warnings
from collections import Counterimport contextily as cx
import folium
import geopandas as gpd
import matplotlib as mpl
import matplotlib.colors as colors
import matplotlib.pyplot as plt
import numpy as np
import osmnx as ox
import pandas as pd
import yaml
from matplotlib import cm
from collections import Counterfrom src import evaluation_functions as eval_func
from src import graph_functions as graph_func
from src import plotting_functions as plot_func# Read in dictionaries with settings
%run ../settings/yaml_variables.py
%run ../settings/plotting.py
%run ../settings/tiledict.py
%run ../settings/df_styler.py# Load data
%run ../settings/load_osmdata.py
%run ../settings/load_refdata.py
%run ../settings/load_results.pywarnings.filterwarnings(ignore)d:\work\miniconda3\envs\bikeDNA\Lib\site-packages\tqdm\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.htmlfrom .autonotebook import tqdm as notebook_tqdm
D:\tmp_resource\BikeDNA-main\BikeDNA-main\scripts\settings\plotting.py:49: MatplotlibDeprecationWarning: The get_cmap function was deprecated in Matplotlib 3.7 and will be removed two minor releases later. Use matplotlib.colormaps[name] or matplotlib.colormaps.get_cmap(obj) instead.cmap cm.get_cmap(cmap_name, n)
D:\tmp_resource\BikeDNA-main\BikeDNA-main\scripts\settings\plotting.py:46: MatplotlibDeprecationWarning: The get_cmap function was deprecated in Matplotlib 3.7 and will be removed two minor releases later. Use matplotlib.colormaps[name] or matplotlib.colormaps.get_cmap(obj) instead.cmap cm.get_cmap(cmap_name)
string:49: MatplotlibDeprecationWarning: The get_cmap function was deprecated in Matplotlib 3.7 and will be removed two minor releases later. Use matplotlib.colormaps[name] or matplotlib.colormaps.get_cmap(obj) instead.
string:46: MatplotlibDeprecationWarning: The get_cmap function was deprecated in Matplotlib 3.7 and will be removed two minor releases later. Use matplotlib.colormaps[name] or matplotlib.colormaps.get_cmap(obj) instead.OSM graphs loaded successfully!
OSM data loaded successfully!
Reference graphs loaded successfully!
Reference data loaded successfully!
Results from intrinsic analyses loaded successfully!OSM versus reference network
plot_func.plot_saved_maps([osm_results_static_maps_fp area_network_osm,ref_results_static_maps_fp area_network_reference,]
)1.数据完整性
本节从数据完整性方面比较 OSM 和参考数据集。 目标是确定一个数据集是否比另一个数据集映射了更多的自行车基础设施如果是这些差异是否集中在某些区域。
本节首先比较两个数据集中基础设施的总长度。 然后首先在全局研究区域和局部网格单元级别比较基础设施、节点和悬空节点密度即每平方公里基础设施/节点的长度。 最后分别比较受保护和未受保护的自行车基础设施的密度差异。
计算网格局部密度差异作为数据质量的度量也已被例如应用。 Haklay (2010)。
方法
为了考虑自行车基础设施映射方式的差异网络长度和密度的计算基于基础设施长度而不是网络边缘的几何长度。 例如一条 100 米长的双向路径几何长度100m贡献了 200 米的自行车基础设施基础设施长度200m。
解释
密度差异可能表明数据不完整。 例如如果网格单元在 OSM 中的边缘密度明显高于参考数据集中的边缘密度则这可能表明参考数据集中未映射、缺失的特征或者街道在 OSM 中被错误地标记为自行车基础设施。
1.1 网络长度
plot_func.compare_print_network_length(osm_edges_simplified.infrastructure_length.sum(),ref_edges_simplified.infrastructure_length.sum(),
)Length of the OSM data set: 1056.49 km
Length of the reference data set: 626.48 kmThe reference data set is 430.01 km shorter than the OSM data set.
The reference data set is 40.70% shorter than the OSM data set.# Plot length comparisonset_renderer(renderer_plot)bar_labels [OSM, reference_name]
x_positions [1, 2]
bar_colors [pdict[osm_base], pdict[ref_base]]# Infrastructure length density
data [osm_edges_simplified.infrastructure_length.sum()/1000,ref_edges_simplified.infrastructure_length.sum()/1000]
y_label Network edge lengths [km]
filepath compare_results_plots_fp network_length_compare
title area_nameplot plot_func.make_bar_plot(datadata,bar_labelsbar_labels,y_labely_label,x_positionsx_positions,titletitle,bar_colorsbar_colors,filepathfilepath,figsizepdict[fsbar_small]
)1.2 网络密度
全球网络密度
plot_func.print_network_densities(osm_intrinsic_results, OSM)
plot_func.print_network_densities(ref_intrinsic_results, reference)In the OSM data, there are:- 5824.58 meters of cycling infrastructure per km2.- 27.65 nodes in the cycling network per km2.- 10.08 dangling nodes in the cycling network per km2.In the reference data, there are:- 3453.85 meters of cycling infrastructure per km2.- 22.74 nodes in the cycling network per km2.- 4.80 dangling nodes in the cycling network per km2.全球网络密度每平方公里
# Plot global differenceset_renderer(renderer_plot)# Infrastructure length density
subplotdata [(osm_intrinsic_results[network_density][edge_density_m_sqkm],ref_intrinsic_results[network_density][edge_density_m_sqkm],),(osm_intrinsic_results[network_density][node_density_count_sqkm],ref_intrinsic_results[network_density][node_density_count_sqkm],),(osm_intrinsic_results[network_density][dangling_node_density_count_sqkm],ref_intrinsic_results[network_density][dangling_node_density_count_sqkm],),
]
subplotx_positions [[1,2] for j in range(3)]
subplotbar_labels [Infrastructure length (m/km2),Total node density (1/km2),Dangling node density (1/km2),
]
filepath compare_results_plots_fp network_densities_compare
subplottitle [Avg infrastructure length per km2,Avg nodes per km2,Avg dangling nodes per km2,
]plot plot_func.make_bar_subplots(subplot_datasubplotdata,nrows1,ncols3,bar_labels[[OSM, reference_name] for j in range(3)],y_labelsubplotbar_labels,x_positionssubplotx_positions,titlesubplottitle,bar_colors[pdict[osm_base], pdict[ref_base]],filepathfilepath,wspace0.4
)本地网络密度
### Plot density comparisonsset_renderer(renderer_map)# Edge density
plot_cols [osm_edge_density, ref_edge_density]
plot_func.plot_multiple_grid_results(gridgrid,plot_colsplot_cols,plot_titles[OSM edge density, f{reference_name} edge density],filepathcompare_results_static_maps_fp density_edge_compare,cmappdict[pos],alphapdict[alpha_grid],cx_tilecx_tile_2,no_data_cols[count_osm_edges, count_ref_edges],use_normTrue,norm_min0,norm_max max(grid[plot_cols].max()),figsize pdict[fsmap],legend False,
)# Node density
plot_cols [osm_node_density, ref_node_density]
plot_func.plot_multiple_grid_results(gridgrid,plot_colsplot_cols,plot_titles[OSM node density, f{reference_name} node density],filepathcompare_results_static_maps_fp density_node_compare,cmappdict[pos],alphapdict[alpha_grid],cx_tilecx_tile_2,no_data_cols[count_osm_nodes, count_ref_nodes],use_normTrue,norm_min0,norm_max max(grid[plot_cols].max()),figsize pdict[fsmap],legend False,
)# Dangling node density
plot_cols [osm_dangling_node_density, ref_dangling_node_density]
plot_func.plot_multiple_grid_results(gridgrid,plot_colsplot_cols,plot_titles[OSM dangling node density, f{reference_name} dangling node density],filepathcompare_results_static_maps_fp density_danglingnode_compare,cmappdict[pos],alphapdict[alpha_grid],cx_tilecx_tile_2,no_data_cols[count_osm_nodes, count_ref_nodes],use_normTrue,norm_min0,norm_max max(grid[plot_cols].max()),figsize pdict[fsmap],legend False,
)网络密度的局部差异
以OSM数据中的密度作为比较基线绝对差值计算为“参考值”-“OSM值”。 因此正值表示基础设施类型的参考密度高于 OSM 密度 负值表示参考密度低于 OSM 密度。
grid[edge_density_diff] grid.ref_edge_density.fillna(0
) - grid.osm_edge_density.fillna(0)grid[node_density_diff] grid.ref_node_density.fillna(0
) - grid.osm_node_density.fillna(0)grid[dangling_node_density_diff] grid.ref_dangling_node_density.fillna(0
) - grid.osm_dangling_node_density.fillna(0)# Network density grid plotsset_renderer(renderer_map)plot_cols [edge_density_diff, node_density_diff, dangling_node_density_diff]
plot_titles [area_name f: {reference_name} edge density differences to OSM (m/km2),area_name f: {reference_name} node density differences to OSM (m/km2),area_name f: {reference_name} dangling node density differences to OSM (m/km2)
]
filepaths [compare_results_static_maps_fp edge_density_compare,compare_results_static_maps_fp node_density_compare,compare_results_static_maps_fp dangling_node_density_compare,
]cmaps [pdict[diff]] * 3# Cols for no-data plots
no_data_cols [(osm_edge_density, ref_edge_density),(osm_node_density, ref_node_density),(osm_dangling_node_density, ref_dangling_node_density),
]cblim_edge max(abs(min(grid[edge_density_diff].fillna(value0))),max(grid[edge_density_diff].fillna(value0)),
)cblim_node max(abs(min(grid[node_density_diff].fillna(value0))),max(grid[node_density_diff].fillna(value0)),
)cblim_d_node max(abs(min(grid[dangling_node_density_diff].fillna(value0))),max(grid[dangling_node_density_diff].fillna(value0)),
)norm_min [-cblim_edge, -cblim_node, -cblim_d_node]
norm_max [cblim_edge, cblim_node, cblim_d_node]plot_func.plot_grid_results(gridgrid,plot_colsplot_cols,plot_titlesplot_titles,filepathsfilepaths,cmapscmaps,alphapdict[alpha_grid],cx_tilecx_tile_2,no_data_colsno_data_cols,use_normTrue,norm_minnorm_min,norm_maxnorm_max,
)受保护和不受保护的自行车基础设施的密度
受保护/未受保护基础设施的全球网络密度
# Plot global differencesset_renderer(renderer_plot)data_labels [protected_density, unprotected_density, mixed_density]
legend_labels [OSM, reference_name]
data_osm [osm_intrinsic_results[network_density][label _m_sqkm] for label in data_labels
]
data_ref [ref_intrinsic_results[network_density][label _m_sqkm] for label in data_labels
]
bar_colors [pdict[osm_base], pdict[ref_base]]
title f{area_name}x_labels [Protected, Unprotected, Mixed]
x_axis [np.arange(len(x_labels)) * 2 - 0.25, np.arange(len(x_labels)) * 2 0.25]
x_ticks np.arange(len(x_labels)) * 2y_label Infrastructure densities (m/km2)filepath compare_results_plots_fp infrastructure_type_density_diff_comparefig plot_func.make_bar_plot_side(x_axisx_axis,data_osmdata_osm,data_refdata_ref,bar_colorsbar_colors,legend_labelslegend_labels,titletitle,x_ticksx_ticks,x_labelsx_labels,x_labelNone,y_labely_label,filepathfilepath,figsizepdict[fsbar_small]
)受保护/未受保护基础设施的本地网络密度
if ref_protected_density in grid.columns:plot_func.plot_saved_maps([osm_results_static_maps_fp density_protected_OSM,ref_results_static_maps_fp density_protected_reference,])else:plot_func.plot_saved_maps([osm_results_static_maps_fp density_protected_OSM] * 2, alpha[1, 0])print(fNo infrastructure is mapped as protected in the {reference_name} data.)if ref_unprotected_density in grid.columns:plot_func.plot_saved_maps([osm_results_static_maps_fp density_unprotected_OSM,ref_results_static_maps_fp density_unprotected_reference,])else:plot_func.plot_saved_maps([osm_results_static_maps_fp density_unprotected_OSM] * 2, alpha[1, 0])print(fNo infrastructure is mapped as unprotected in the {reference_name} data.)if ref_mixed_density in grid.columns:plot_func.plot_saved_maps([osm_results_static_maps_fp density_mixed_OSM,ref_results_static_maps_fp density_mixed_reference,])else:plot_func.plot_saved_maps([osm_results_static_maps_fp density_mixed_OSM] * 2, alpha[1, 0])print(fNo infrastructure is mapped as mixed protected/unprotected in the {reference_name} data.)No infrastructure is mapped as mixed protected/unprotected in the GeoDanmark data.基础设施类型密度的差异
# Computing difference in infrastructure type density# In case no infrastructure with mixed protected/unprotected exist
if osm_mixed_density not in grid.columns:grid[osm_mixed_density] 0if ref_mixed_density not in grid.columns:grid[ref_mixed_density] 0if ref_protected_density not in grid.columns:grid[ref_protected_density] 0if ref_unprotected_density not in grid.columns:grid[ref_unprotected_density] 0grid[protected_density_diff] grid.ref_protected_density.fillna(0
) - grid.osm_protected_density.fillna(0)
grid[unprotected_density_diff] grid.ref_unprotected_density.fillna(0
) - grid.osm_unprotected_density.fillna(0)
grid[mixed_density_diff] grid.ref_mixed_density.fillna(0
) - grid.osm_mixed_density.fillna(0)# Infrastructure type density grid plotsset_renderer(renderer_map)plot_cols [protected_density_diff, unprotected_density_diff, mixed_density_diff]
plot_cols [c for c in plot_cols if c in grid.columns]
plot_titles [area_name f: {reference_name} protected infrastructure density differences to OSM (m/km2),area_name f: {reference_name} unprotected infrastructure density differences to OSM (1/km2),area_name f: {reference_name} mixed infrastructure density differences to OSM (1/km2),
]filepaths [compare_results_static_maps_fp protected_density_compare,compare_results_static_maps_fp unprotected_density_compare,compare_results_static_maps_fp mixed_density_compare,
]cmaps [pdict[diff]] * len(plot_cols)# Cols for no-data plots
no_data_cols [(osm_edge_density, ref_edge_density),(osm_edge_density, ref_edge_density),(osm_edge_density, ref_edge_density),
]# Create symmetrical color range around zero
cblim max(abs(min(grid[plot_cols].fillna(value0).min())),max(grid[plot_cols].fillna(value0).max()),
)norm_min [-cblim] * len(plot_cols)
norm_max [cblim] * len(plot_cols)plot_func.plot_grid_results(gridgrid,plot_colsplot_cols,plot_titlesplot_titles,filepathsfilepaths,cmapscmaps,alphapdict[alpha_grid],cx_tilecx_tile_2,no_data_colsno_data_cols,use_normTrue,norm_minnorm_min,norm_maxnorm_max,
)2.网络拓扑结构
在比较数据完整性即映射了“多少”基础设施之后这里我们重点关注网络“拓扑”的差异它提供了有关“如何”基础设施在两个数据集中映射的信息。 在这里我们还分析网络边与一个或多个其他边连接的程度或者它们是否以悬空节点结束。 边缘与相邻边缘正确连接的程度对于可访问性和路由分析等非常重要。
在处理自行车网络上的数据时首选实际连接的网络元素之间没有间隙的数据集 - 当然反映了真实情况。 识别网络中的悬空节点是识别以“死胡同”结束的边缘的快速且简单的方法。 下冲和过冲分别提供了网络间隙和过度延伸边缘的更精确图像这给出了悬空节点的误导性计数。
方法
为了识别数据中潜在的间隙或缺失的链接首先绘制两个数据集中的悬空节点。 然后单独绘制每个数据集中所有节点中悬挂节点的局部百分比。 最后我们显示了悬空节点百分比的局部差异。
OSM 和参考数据中的欠调和过调最终会一起绘制在交互式图中以供进一步检查。
解释
如果一条边在一个数据集中以悬空节点结束但在另一个数据集中却没有则表明数据质量存在问题。 数据中缺少连接或者两条边连接错误。 类似地悬空节点份额的不同局部率表明自行车网络的映射方式存在差异——尽管在解释中当然应该考虑数据完整性的差异。
下冲是网络数据中误导性差距的明显迹象——尽管它们也可能代表自行车基础设施中的实际差距。 将一个数据集与另一数据集的下冲进行比较可以帮助确定这是数据质量问题还是实际基础设施的质量问题。 交叉口之间存在下冲或间隙的系统差异可能表明不同的数字化策略因为一些方法会将穿过街道的自行车道绘制为连接的延伸段而其他方法则会在交叉街道的宽度上引入间隙。 虽然这两种方法都是有效的但使用前一种方法创建的数据集更适合基于路由的分析。
超调对于分析来说通常不太重要但大量的超调会引入错误的悬空节点并扭曲基于节点度或节点与边之间的比率等网络结构的测量。
2.1 简化结果 print(fSimplifying the OSM network decreased the number of edges by {osm_intrinsic_results[simplification_outcome][edge_percent_diff]:.1f}%.
)
print(fSimplifying the OSM network decreased the number of nodes by {osm_intrinsic_results[simplification_outcome][node_percent_diff]:.1f}%.
)
print(\n)
print(fSimplifying the {reference_name} network decreased the number of edges by {ref_intrinsic_results[simplification_outcome][edge_percent_diff]:.1f}%.
)
print(fSimplifying the {reference_name} network decreased the number of nodes by {ref_intrinsic_results[simplification_outcome][node_percent_diff]:.1f}%.
)
Simplifying the OSM network decreased the number of edges by 89.0%.
Simplifying the OSM network decreased the number of nodes by 84.4%.Simplifying the GeoDanmark network decreased the number of edges by 91.2%.
Simplifying the GeoDanmark network decreased the number of nodes by 92.2%.Node degree distribution
degree_sequence_before_osm sorted((d for n, d in osm_graph.degree()), reverseTrue)
degree_sequence_after_osm sorted((d for n, d in osm_graph_simplified.degree()), reverseTrue
)degree_sequence_before_ref sorted((d for n, d in ref_graph.degree()), reverseTrue)
degree_sequence_after_ref sorted((d for n, d in ref_graph_simplified.degree()), reverseTrue
)# Display already saved degree distribution plotsprint(Note that the two figures below have different y-axis scales.)plot_func.plot_saved_maps([osm_results_plots_fp degree_dist_osm,ref_results_plots_fp degree_dist_reference]
)Note that the two figures below have different y-axis scales.2.2 Alpha、beta 和 gamma 指数
在本小节中我们计算并对比三个聚合网络指标 alpha、beta 和 gamma。 这些指标通常用于描述网络结构但作为数据质量的衡量标准它们仅在与相应数据集的值进行比较时才有意义。 因此alpha、beta 和 gamma 仅是外在分析的一部分不包含在内在笔记本中。
虽然无法根据这三个指标中的任何一个本身得出有关数据质量的结论但对两个数据集的指标进行比较可以表明网络拓扑的差异从而表明基础设施映射方式的差异。
方法
所有三个索引均使用“eval_func.compute_alpha_beta_gamma”计算。
alpha 值是网络中实际与可能的周期的比率。 网络循环被定义为闭环 - 即在其起始节点上结束的路径。 alpha值的范围是0到1。alpha值为0意味着网络根本没有环即它是一棵树。 alpha 值为 1 意味着网络完全连接但这种情况很少见。
beta 值是网络中现有边与现有节点的比率。 beta的取值范围是0到N-1其中N是现有节点的数量。 beta值为0意味着网络没有边 Beta 值为 N-1 意味着网络完全连接另请参见 gamma 值 1。 beta 值越高在任意一对节点之间可以选择的不同路径平均就越多。
gamma 值是网络中现有边与可能边的比率。 连接两个现有网络节点的任何边都被定义为“可能”。 因此gamma 的取值范围为 0 到 1。gamma 值为 0 表示网络没有边gamma 值为 0 表示网络没有边 gamma 值为 1 意味着网络的每个节点都连接到每个其他节点。
对于所有三个指数请参阅 Ducruet 和 Rodrigue2020。 所有三个指数都可以根据网络连接性进行解释 alpha 值越高网络中存在的周期越多 beta值越高路径数量越多网络复杂度越高 伽马值越高任何一对节点之间的边越少。
解释
这些指标并没有过多说明数据质量本身也对于类似规模的网络的拓扑比较没有用处。 不过通过比较还是可以得出一些结论。 例如如果两个网络的索引非常相似尽管网络例如 具有非常不同的几何长度这表明数据集是以大致相同的方式映射的但一个数据集只是比另一个包含更多的特征。 然而如果网络的总几何长度大致相同但 alpha、beta 和 gamma 的值不同则这可能表明两个数据集的结构和拓扑根本不同。
osm_alpha, osm_beta, osm_gamma eval_func.compute_alpha_beta_gamma(edgesosm_edges_simplified,nodesosm_nodes_simplified,Gosm_graph_simplified,planarTrue,
) # We assume network to be planar or approximately planarprint(fAlpha for the simplified OSM network: {osm_alpha:.2f})
print(fBeta for the simplified OSM network: {osm_beta:.2f})
print(fGamma for the simplified OSM network: {osm_gamma:.2f})print(\n)ref_alpha, ref_beta, ref_gamma eval_func.compute_alpha_beta_gamma(ref_edges_simplified, ref_nodes_simplified, ref_graph_simplified, planarTrue
) # We assume network to be planar or approximately planarprint(fAlpha for the simplified {reference_name} network: {ref_alpha:.2f})
print(fBeta for the simplified {reference_name} network: {ref_beta:.2f})
print(fGamma for the simplified {reference_name} network: {ref_gamma:.2f})Alpha for the simplified OSM network: 0.11
Beta for the simplified OSM network: 1.15
Gamma for the simplified OSM network: 0.38Alpha for the simplified GeoDanmark network: 0.10
Beta for the simplified GeoDanmark network: 1.14
Gamma for the simplified GeoDanmark network: 0.38# Plot alpha, beta, gammaset_renderer(renderer_plot)bar_labels [OSM, reference_name]bar_colors [pdict[osm_base], pdict[ref_base]]subplot_data [(len(osm_nodes_simplified), len(ref_nodes_simplified)),(len(osm_edges_simplified), len(ref_edges_simplified)),(osm_edges_simplified.geometry.length.sum()/1000,ref_edges_simplified.geometry.length.sum()/1000,),(osm_alpha, ref_alpha),(osm_beta, ref_beta),(osm_gamma, ref_gamma),
]
y_label [,,,,,,
]
subplottitle [Total nodes, Total edges, Network length (km), Alpha, Beta, Gamma]
filepath compare_results_plots_fp alpha_beta_gammaplot plot_func.make_bar_subplots(subplot_datasubplot_data,nrows2,ncols3,bar_labels[[OSM, reference_name] for j in range(6)],y_labely_label,x_positions[[1,2] for j in range(6)],titlesubplottitle,bar_colorsbar_colors,filepathfilepath,wspace0.4
);2.3 悬空节点
osm_dangling_nodes gpd.read_file(osm_results_data_fp dangling_nodes.gpkg)
ref_dangling_nodes gpd.read_file(ref_results_data_fp dangling_nodes.gpkg)OSM 和参考网络中的悬空节点
# Interactive plot of dangling nodesosm_edges_simplified_folium plot_func.make_edgefeaturegroup(gdfosm_edges_simplified,mycolorpdict[osm_base],myweightpdict[line_base],nametagOSM edges,show_edgesTrue,
)osm_nodes_simplified_folium plot_func.make_nodefeaturegroup(gdfosm_nodes_simplified,mysizepdict[mark_base],mycolorpdict[osm_base],nametagOSM all nodes,show_nodesTrue,
)osm_dangling_nodes_folium plot_func.make_nodefeaturegroup(gdfosm_dangling_nodes,mysizepdict[mark_emp],mycolorpdict[osm_contrast],nametagOSM dangling nodes,show_nodesTrue,
)ref_edges_simplified_folium plot_func.make_edgefeaturegroup(gdfref_edges_simplified,mycolorpdict[ref_base],myweightpdict[line_base],nametagReference edges,show_edgesTrue,
)ref_nodes_simplified_folium plot_func.make_nodefeaturegroup(gdfref_nodes_simplified,mysizepdict[mark_base],mycolorpdict[ref_base],nametagReference all nodes,show_nodesTrue,
)ref_dangling_nodes_folium plot_func.make_nodefeaturegroup(gdfref_dangling_nodes,mysizepdict[mark_emp],mycolorpdict[ref_contrast2],nametagReference dangling nodes,show_nodesTrue,
)m plot_func.make_foliumplot(feature_groups[osm_edges_simplified_folium,osm_nodes_simplified_folium,osm_dangling_nodes_folium,ref_edges_simplified_folium,ref_nodes_simplified_folium,ref_dangling_nodes_folium,],layers_dictfolium_layers,center_gdfosm_nodes_simplified,center_crsosm_nodes_simplified.crs,
)bounds plot_func.compute_folium_bounds(osm_nodes_simplified)
m.fit_bounds(bounds)
m.save(compare_results_inter_maps_fp danglingmap_compare.html)display(m)print(Interactive map saved at compare_results_inter_maps_fp.lstrip(../) danglingmap_compare.html)Interactive map saved at results/COMPARE/cph_geodk/maps_interactive/danglingmap_compare.html悬空节点的局部值
# Compute pct difference relative to OSMgrid[dangling_nodes_diff_pct] np.round(100* (grid.count_ref_dangling_nodes - grid.count_osm_dangling_nodes)/ grid.count_osm_dangling_nodes,2,
)悬空节点占所有节点的百分比
plot_func.plot_saved_maps([osm_results_static_maps_fp pct_dangling_nodes_osm,ref_results_static_maps_fp pct_dangling_nodes_reference,]
)悬空节点百分比的局部差异
# Plotset_renderer(renderer_map)# norm color bar
cbnorm_dang_diff colors.Normalize(vmin-100, vmax100) # from -max to maxfig, ax plt.subplots(1, figsizepdict[fsmap])
from mpl_toolkits.axes_grid1 import make_axes_locatable
divider make_axes_locatable(ax)
cax divider.append_axes(right, size3.5%, pad1%)grid.plot(caxcax,axax,alphapdict[alpha_grid],columndangling_nodes_diff_pct,cmappdict[diff],legendTrue,normcbnorm_dang_diff,
)# Add no data patches
grid[grid[dangling_nodes_diff_pct].isnull()].plot(caxcax,axax,facecolorpdict[nodata_face],edgecolorpdict[nodata_edge],linewidth pdict[line_nodata],hatchpdict[nodata_hatch],alphapdict[alpha_nodata],
)ax.legend(handles[nodata_patch], locupper right)ax.set_title(area_name f: {reference_name} percent difference to OSM in dangling nodes
)
ax.set_axis_off()
cx.add_basemap(axax, crsstudy_crs, sourcecx_tile_2)plot_func.save_fig(fig, compare_results_static_maps_fp dangling_nodes_pct_diff_compare)下冲/过冲
# USER INPUT: LENGTH TOLERANCE FOR OVER- AND UNDERSHOOTS
length_tolerance_over 3
length_tolerance_under 3for s in [length_tolerance_over, length_tolerance_under]:assert isinstance(s, int) or isinstance(s, float), print(Settings must be integer or float values!)osm_overshoot_ids pd.read_csv(osm_results_data_fp fovershoot_edges_{length_tolerance_over}.csv
)[edge_id].to_list()
osm_undershoot_ids pd.read_csv(osm_results_data_fp fundershoot_nodes_{length_tolerance_under}.csv
)[node_id].to_list()ref_overshoot_ids pd.read_csv(ref_results_data_fp fovershoot_edges_{length_tolerance_over}.csv
)[edge_id].to_list()
ref_undershoot_ids pd.read_csv(ref_results_data_fp fundershoot_nodes_{length_tolerance_under}.csv
)[node_id].to_list()osm_overshoots osm_edges_simplified.loc[osm_edges_simplified.edge_id.isin(osm_overshoot_ids)
]
ref_overshoots ref_edges_simplified.loc[ref_edges_simplified.edge_id.isin(ref_overshoot_ids)
]
ref_undershoots ref_nodes_simplified.loc[ref_nodes_simplified.nodeID.isin(ref_undershoot_ids)
]
osm_undershoots osm_nodes_simplified.loc[osm_nodes_simplified.osmid.isin(osm_undershoot_ids)
]OSM 和参考网络中的过冲和下冲
# Interactive plot of over/undershootsfeature_groups []# OSM feature groups
osm_edges_simplified_folium plot_func.make_edgefeaturegroup(gdfosm_edges_simplified,mycolorpdict[osm_base],myweightpdict[line_base],nametagOSM network,show_edgesTrue,
)feature_groups.append(osm_edges_simplified_folium)if len(osm_overshoots) 0:osm_overshoots_folium plot_func.make_edgefeaturegroup(gdfosm_overshoots,mycolorpdict[osm_contrast],myweightpdict[line_emp],nametagOSM overshoots,show_edgesTrue,)feature_groups.append(osm_overshoots_folium)if len(osm_undershoots) 0:osm_undershoot_nodes_folium plot_func.make_nodefeaturegroup(gdfosm_undershoots,mysizepdict[mark_emp],mycolorpdict[osm_contrast2],nametagOSM undershoot nodes,show_nodesTrue,)feature_groups.append(osm_undershoot_nodes_folium)# Reference feature groups
ref_edges_simplified_folium plot_func.make_edgefeaturegroup(gdfref_edges_simplified,mycolorpdict[ref_base],myweightpdict[line_base],nametagf{reference_name} network,show_edgesTrue,
)feature_groups.append(ref_edges_simplified_folium)if len(ref_overshoots) 0:ref_overshoots_folium plot_func.make_edgefeaturegroup(gdfref_overshoots,mycolorpdict[ref_contrast],myweightpdict[line_emp],nametagf{reference_name} overshoots,show_edgesTrue,)feature_groups.append(ref_overshoots_folium)if len(ref_undershoots) 0:ref_undershoot_nodes_folium plot_func.make_nodefeaturegroup(gdfref_undershoots,mysizepdict[mark_emp],mycolorpdict[ref_contrast2],nametagf{reference_name} undershoot nodes,show_nodesTrue,)feature_groups.append(ref_undershoot_nodes_folium)m plot_func.make_foliumplot(feature_groupsfeature_groups,layers_dictfolium_layers,center_gdfosm_nodes_simplified,center_crsosm_nodes_simplified.crs,
)bounds plot_func.compute_folium_bounds(osm_nodes_simplified)
m.fit_bounds(bounds)m.save(compare_results_inter_maps_fp foverundershoots_{length_tolerance_over}_{length_tolerance_under}_compare.html
)display(m)print(Interactive map saved at compare_results_inter_maps_fp.lstrip(../) foverundershoots_{length_tolerance_over}_{length_tolerance_under}_compare.html)Interactive map saved at results/COMPARE/cph_geodk/maps_interactive/overundershoots_3_3_compare.html3.网络组件
见链接
4.概括
见链接
5.保存结果
见链接