过滤postgis的openstreetmap数据

问题描述:

我正在创建一个postgis数据库,并且想要使用过滤的OpenStreetMap数据。过滤postgis的openstreetmap数据

为此,我曾尝试以下过程:* .osm使用到的bzip2

  1. 下载的文件planet.osm.bz2从https://planet.osm.org/
  2. 解压缩后的
  3. 过滤使用osmfilter通过命令文件提示
  4. 上传在命令提示符下使用osm2pgsql过滤的* .osm文件到我的数据库

对于我的第一次尝试,我只是过滤了土地面积。

然而,步骤4使用osm2pgsql中,我收到以下错误在命令提示:“Osm2pgsql失败,由于错误:不 合式(标记无效) :XML在行3137102,塔61分析错误“

作为从命令提示显示我的视窗的计算机上:

Z:\OpenStreetMap>osm2pgsql -U postgres -W -m -d osm -p filteredland -S "C:\Progr 
 
am Files (x86)\HOTOSM\share\default.style" filteredland2.osm 
 
osm2pgsql version 0.92.0 (64 bit id space) 
 

 
Password: 
 
Using built-in tag processing pipeline 
 
Using projection SRS 3857 (Spherical Mercator) 
 
Setting up table: filteredland_point 
 
Setting up table: filteredland_line 
 
Setting up table: filteredland_polygon 
 
Setting up table: filteredland_roads 
 
Allocating memory for sparse node cache 
 
Node-cache: cache=800MB, maxblocks=12800*65536, allocation method=1 
 
Mid: Ram, scale=100 
 

 
Reading in file: filteredland2.osm 
 
Using XML parser. 
 
Processing: Node(1230k 61.5k/s) Way(0k 0.00k/s) Relation(0 0.00/s)node cache: st 
 
ored: 1233078(100.00%), storage efficiency: 50.00% (dense blocks: 0, sparse node 
 
s: 1233078), hit rate: -nan(ind)% 
 
Osm2pgsql failed due to ERROR: XML parsing error at line 3137102, column 61: not 
 
well-formed (invalid token)

我还试图两个备用路由,这也失败:

  1. 下载planet.pbf - >转换为.o5m使用osmconvert - > 过滤使用osmfilter

  2. 下载planet.pbf - >转换使用osmconvert到.osm - > 过滤使用osmfilter(都给警告) - >使用osm2pgsql到 传递到数据库

任何知道如何避免这个错误,或者有过滤planet.osm文件并上传到postgis的经验?

我建议使用Osmium而不是osmfilter,它不需要首先将行星转换为不同的格式,并且本地可以返回可由osm2pgsql直接处理的PBF数据。它也更快。