2012-07-23 77 views
0

R中的osmar包中包含一個名爲demo("navigator")的演示文件。它提供了說明包的功能和功能。當我十劇本,我打下面的行和錯誤:osmar封裝在R(OpenStreetMap)

R> muc <- get_osm(muc_bbox, src) 
sh: osmosis: command not found 
Error in file(con, "r") : cannot open the connection 
In addition: Warning message: 
In file(con, "r") : 
    cannot open file '/var/folders/81/4k487q0969q1d8rfd1pyhyr40000gs/T//RtmpdgZSOy/file13a473cb904c': No such file or directory 

該命令旨在將osmosis數據對象轉換爲osmar對象。我已經正確安裝了MacOSX的osmosis,在bash shell中更新了我的路徑定義以指向osmosis可執行文件。

我不確定錯誤信息的含義以及如何最好地迴應。任何幫助讚賞 布拉德

回答

1

有你的重新啓動R?它看起來像滲透不在你的道路上,雖然你確實提到你設置了它。請確保您可以在終端運行滲透的一個命令:

osmosis --read-xml SloveniaGarmin.osm --tee 4 --bounding-box left=15 top=46 --write-xml SloveniaGarminSE.osm --bounding-box left=15 bottom=46 --write-xml SloveniaGarminNE.osm --bounding-box right=15 top=46 --write-xml SloveniaGarminSW.osm --bounding-box right=15 bottom=46 --write-xml SloveniaGarminNW.osm 

的例子是無關緊要的,只要它沒有說找不到osmosis文件。

此外,請確保您的路徑中有gzip。我幾乎可以肯定它是默認的,但demo軟件包依靠它運行。只要打開一個終端並鍵入gzip以確保它在那裏。

最後,如果你需要調試這一點,那麼運行這個命令:

library(osmar) 
download.file("http://osmar.r-forge.r-project.org/muenchen.osm.gz","muenchen.osm.gz") 
system("gzip -d muenchen.osm.gz") 
# At this point, check the directory listed by getwd(). It should contain muenchen.osm. 
src <- osmsource_osmosis(file = "muenchen.osm",osmosis = "osmosis") 
muc_bbox <- center_bbox(11.575278, 48.137222, 3000, 3000) 
debug(osmar:::get_osm_data.osmosis) 
get_osm(muc_bbox, src) 
# Press Enter till you get to 
# request <- osm_request(source, what, destination) 
# Then type request to get the command it is sending. 

後鍵入回車一次,然後request你會得到它發送到您的操作系統的字符串。它應該是這樣的:

osmosis --read-xml enableDateParsing=no file=muenchen.osm --bounding-box top=48.1507120588903 left=11.5551240885889 bottom=48.1237319411097 right=11.5954319114111 --write-xml file=<your path> 

嘗試粘貼到您的終端。它應該從任何目錄工作。

唉,並輸入undebug(osmar:::get_osm_data.osmosis)停止調試。鍵入Q退出調試器。

1

嘿,我剛剛得到這個東西的工作。問題不在於滲透系統路徑變量。系統調用使用「gzip」應用程序解壓縮之前下載的.gz文件的腳本。因此,當您的機器中未安裝gzip或者gzip不在系統路徑變量中時會出現錯誤。所以安裝gzip並將其添加到路徑變量將緩解此錯誤。或者,您可以手動將文件解壓縮到相同路徑並再次運行腳本。