terminal and subprocess.run()显示命令的不同行为(osmfilter)

问题描述 投票:0回答:1

我看到了可以通过以下命令安装的osmfilter(https://wiki.openstreetmap.org/wiki/Osmfilter)的特殊行为:

$ sudo apt-get install osmctools

假设我从https://www.openstreetmap.org中导出了一个区域的map.osm,而我只想从该文件中过滤高速公路。我可以使用的命令是:

$ osmfilter map.osm --keep='highway' > highways_terminal.osm

文件highways_terminal.osm包含有关高速公路的信息。然后,我尝试使用Python对subprocess.run()执行相同的操作:

import subprocess

cmd = ["osmfilter", "map.osm", "--keep='highway'"]
resp = subprocess.run(cmd, capture_output=True, text=True)

with open("highways_subprocess.osm", "w") as fp:
    fp.write(resp.stdout)

但是,highways_subprocess.osm除“界限”外不包含其他信息。

我处理引号不正确吗?

python terminal subprocess openstreetmap
1个回答
0
投票

我遇到了这个问题(10个月后),并将其修复为

© www.soinside.com 2019 - 2024. All rights reserved.