OSM踩坑记录

1. 下载数据

从https://www.openstreetmap.org/下载数据(如'map.osm')

2.转换格式

安装gdal,我用的cuda

conda install -c conda-forge gdal

如果报错可能需要回到base(退出虚拟环境)再更新一下conda

conda update --all

 

然后转换数据,从osm到geojson

ogr2ogr -f GeoJSON map.geo.json map.osm

这个可能报错情况:

1. 缺少osmconf.ini配置文件

Warning 1: Cannot find osmconf.ini configuration file
ERROR 1: Could not parse configuration file for OSM import

下载好放在转换文件('map.osm')同目录下即可

2. Layer XXX不存在

Warning 1: Input datasource uses random layer reading, but output datasource does not support random layer writing
0ERROR 1: Layer 'lines' does not already exist in the output dataset, and cannot be created by the output driver.

命令中添加对应的层

ogr2ogr -f GeoJSON map.geo.json map.osm lines

 3. 查看geojson文件(可视化)

打开网站:http://geojson.io/并读取文件

 

posted @ 2023-06-07 19:18  拎壶冲AR  阅读(85)  评论(0编辑  收藏  举报