를 전송하지 않습니다,하지만 난 OSM 데이터에서 타일 생성을 자동화하기 위해이 코드를 실행하는 데 문제입니다 :파이썬 하위 프로세스 내가 <a href="http://wiki.openstreetmap.org/wiki/Osmosis" rel="nofollow noreferrer">osmosis</a> 대형 OSM 파일에서 데이터를 추출하는 과정을 자동화 할 인수를
import sys
import subprocess
def create_tile_pbf(pbf_file, tile_lng, tile_lat):
"""Runs the osmosis tile creator"""
app_path = "osmosis/bin/"
app = "osmosis.bat"
proc = subprocess.Popen([
app_path + app,
"--read-pbf", pbf_file,
"--bounding-box",
"top=%d" % (tile_lat+1),
"left=%d" % (tile_lng),
"bottom=%d" % (tile_lat),
"right=%d" % (tile_lng+1),
"--write-pbf", "someotherfile.osm.pbf"
], cwd=app_path, shell=True)
# Poll the proc to see if it is finished
while proc.returncode is None:
proc.communicate()
proc.poll()
print(">> Terminated\n")
if __name__ == "__main__":
print("Args were: " + str(sys.argv) + "\n")
create_tile_pbf("./somefile.osm.pbf", 7, 46)
I을 shell=True
과 함께 시도했지만, 모든 인수를 단일 문자열에 결합하려고했습니다. 그것을 실행하지만 난 항상이 오류가 : 파워 쉘 또는 명령 프롬프트 명령을 실행할 때
Nov 03, 2017 2:26:28 PM org.openstreetmap.osmosis.core.Osmosis main
SEVERE: Execution aborted.
org.openstreetmap.osmosis.core.OsmosisRuntimeException: Expected argument 1 to be an option or task name.
at org.openstreetmap.osmosis.core.cli.CommandLineParser.parse(CommandLineParser.java:79)
at org.openstreetmap.osmosis.core.Osmosis.run(Osmosis.java:74)
at org.openstreetmap.osmosis.core.Osmosis.main(Osmosis.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
그러나, 그것은 마법처럼 작동합니다.
.\osmosis.bat --read-pbf .\somefile.osm.pbf --bounding-box top=47 left=7 bottom=46 right=8 --write-pbf someotherfile.osm.pbf
저는 Anaconda 4.3.30이 설치된 Windows 10 1703 64 비트를 실행하고 있습니다.
echo % 1 % 2 ...와 (과) 함께 자신의 osmosis.bat를 만들어 호출 방법을 확인하십시오. –