【问题标题】:osmar package in R (OpenStreetMap)R 中的 osmar 包(OpenStreetMap)
【发布时间】:2012-07-23 20:12:25
【问题描述】:

R 中的osmar 包有一个名为demo("navigator") 的演示文件。提供它是为了说明包的能力和功能。当我十个脚本时,我遇到了以下行并出现错误:

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 可执行文件。

我不确定错误消息的含义以及如何最好地响应。任何帮助表示赞赏 布拉德

【问题讨论】:

    标签: r openstreetmap osmar


    【解决方案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 file not found。

    另外,请确保您的路径中有 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.
    

    在您输入一次 Enter 后,然后输入 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 退出调试器。

    【讨论】:

      【解决方案2】:

      嘿,我刚刚弄好了这个东西。问题不在于渗透的系统路径变量。它与系统调用脚本使用“gzip”应用程序解压缩之前下载的.gz 文件。所以当你的机器上没有安装 gzip 或者 gzip 不在系统路径变量中时会出现错误。因此安装 gzip 并将其添加到路径变量将减轻此错误。或者,您可以手动将文件解压缩到相同的路径并再次运行脚本。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-10-08
        • 1970-01-01
        • 2020-09-26
        • 1970-01-01
        • 1970-01-01
        • 2021-06-15
        • 2021-06-17
        相关资源
        最近更新 更多