2022年底,微软宣布将发布超过4780万公里的道路数据。浅浅用python可视化一下。
Microsoft Maps AI 团队已从 Open Street Maps (OSM) 中检测到4780 万公里的所有道路和116 万公里的缺失道路。这些新道路是使用 Bing 地图在 2020 年至 2022 年期间收集的图像检测到的,包括来自 Maxar 和空中客车公司的来源。
完整的数据可以从下列地址下载,当然没有中国的数据,所以看看就好
https://github.com/microsoft/RoadDetections
道路的年份取决于基础图像的年份。因为 Bing Imagery 是多个来源的组合,所以很难知道单个数据的确切日期。
OSM缺失数据经过最终分类器以确保精度至少为 95%(美国现在为 90% - 将在 2022 年更新为 95%)。分类器过滤掉潜在的坏路后,我们重新测量精度并确保在发布结果之前它是 95%
由于是神经网络AI提取,所以基本没有什么数据属性可言。个人认为有各种属性,例如普通道路、高速公路、单行道和行驶方向的数据才被称之为数据。如果没有这些,作为可视化背景看看就行。
githup好像都被无语住了,说好的发布 GeoJson 格式,结果发布个tsv格式,真的逼得人骂娘
还好有大佬出手写了一下代码,可以将tsv格式数据转为GeoJson 格式
https://github.com/rabenojha/microsoft-road-data/blob/main/road_data_processing.ipynb
这里又遇见一个问题,因为我是在ArcGIS Pro写的代码,安装gdal还有geopandas就浪费了好多时间我感觉我又可以水一篇教程了
#将tsv格式数据转为GeoJson 格式
import json
import geopandas as gpd
import pandas as pd
from osgeo import gdal
df = pd.read_csv('F:\chrome_download\AsiaSouthEast-Full\AsiaSouthEast-Full.tsv', sep='\t',header=None)
df
# adding column name as the dataframe has no column names
df.columns =['Country', 'Feature']
# selecting one specific country for faster processing (NPL for Nepal)
df2 = df [df['Country'] == 'MYS']
df2
# creates 'output.geojson' in your pwd
features = []
for _, row in df2.iterrows():
feature = json.loads(row['Feature'])
features.append(feature)
geojson = {
'type': 'FeatureCollection',
'features': features
}
with open('output.geojson', 'w') as f:
json.dump(geojson, f)
# converts above created geojson file to 'output.gpkg'
geojson_ds = gdal.OpenEx('output.geojson', gdal.OF_VECTOR)
driver = gdal.GetDriverByName('GPKG')
output_ds = driver.Create('output.gpkg', 0, 0, 0, gdal.GDT_Unknown)
gdal.VectorTranslate(output_ds, geojson_ds, format='GPKG')
output_ds = None
需要注意的是第一列为所在地区国家简称
所以我真的有在用ArcGIS Pro写代码(3.0界面真TM丑,谁用谁知道)
import geopandas as gpd
import matplotlib.pyplot as plt
# 读取 GeoJSON 文件
gdf = gpd.read_file(r"C:\Users\zheyu\Desktop\output.geojson")
# 绘制地图
gdf.plot()
# 添加图注
plt.title("Malaysia road visualization")
plt.xlabel("Longitude")
plt.ylabel("Latitude")
# 显示地图
plt.show()
结果如下,下为马来西亚的全国道路
放大效果如下
所以这真的是一篇很无聊的教程。