osmar::get_osm() 函数出错,下载OSM数据失败:SYSTEM或PUBLIC,URI缺失。

6

我正在跟随一个教程学习如何使用osmar包在R中下载OSM数据,所以代码如下:

library(osmar)
src <- osmsource_api()
bb <- center_bbox(174.76778, -36.85056, 700, 700)
ua <- get_osm(bb, source = src)

当我运行这最后一行时,会出现以下错误:
Space required after the Public Identifier
SystemLiteral " or ' expected
SYSTEM or PUBLIC, the URI is missing
Opening and ending tag mismatch: hr line 7 and body
Opening and ending tag mismatch: body line 4 and html
Premature end of data in tag html line 2
Error: 1: Space required after the Public Identifier
2: SystemLiteral " or ' expected
3: SYSTEM or PUBLIC, the URI is missing
4: Opening and ending tag mismatch: hr line 7 and body
5: Opening and ending tag mismatch: body line 4 and html
6: Premature end of data in tag html line 2

我不确定这是什么意思。当我谷歌这个错误时,我只能看到与Bioconductor和biomaRt相关的东西,这与我正在工作的内容无关。但是,我相信这与R连接OSM网站有关(?)。因此,我想知道是否有人知道如何解决它。谢谢!


2
这可能是包本身的问题,因为给定的包示例产生了完全相同的错误。您可以尝试编写包维护者。您可以在包文档中找到电子邮件地址。 - SeGa
1
不要提供可以使用文本的图像信息。 - Kalle Richter
1个回答

12

你看到的错误信息是关于服务器返回的以下响应。它基本上意味着osmar包正在尝试通过HTTP下载,但服务器将您重定向到HTTPS位置。由于某种原因,osmar没有遵循此重定向并失败了。您可能应该向软件包所有者报告此问题以解决它。

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://www.openstreetmap.org/api/0.6/map/?bbox=174.763855598139,-36.8537138679267,174.771704401861,-36.8474061320733">here</a>.</p>
<hr>
<address>Apache/2.4.18 (Ubuntu) Server at api.openstreetmap.org Port 80</address>
</body></html>

一个简单的解决方案是提供带有HTTPS的正确URL:

src <- osmsource_api(url = "https://api.openstreetmap.org/api/0.6/")

顺便提一下:OSM API(也就是你所使用的终端)仅仅用于地图编辑。因此,所有这些可能都违反了该服务的使用条款。最好使用一些基于OSM镜像或Overpass API的替代方案。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接