r - osmar::get_osm()下载OSM数据时出错:SYSTEM或PUBLIC,缺少URI

标签 r openstreetmap osmar

我正在关注tutorial有关如何使用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网站(?)的连接有关。所以我想知道是否有人知道如何修复它的提示。谢谢!

最佳答案

您看到的错误消息是指服务器的以下响应。基本上,这意味着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(您正在使用的端点)仅用于编辑 map 。因此,毕竟这可能违反了该服务的使用条款。最好使用一些基于OSM镜像或Overpass API的替代方法。

关于r - osmar::get_osm()下载OSM数据时出错:SYSTEM或PUBLIC,缺少URI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50428697/

相关文章:

r - h2o 中可定制的交叉验证(取决于训练集的功能)

postgresql - 使用 Docker 创建 OSM 磁贴服务器的问题

r - glmnet 4.0 负二项式回归 : "Error in seq.default(log(lambda_max), log(lambda_max * lambda.min.ratio), : ' from' must be a finite number"

r - 如何使用 `rstudioapi::insertText` 缩进

r - 将 data.frames(n x 2 data.frames)列表 reshape 为单个 data.frame(n x 3 列)

mysql - 在哪里存储有关路线和地点的信息?

android - osmdroid 错误的 RoadManager

r - 如何使用osmar提取osm数据

r - 根据 gps 坐标列表更改基于开放街道 map 的 igraph 中路径边缘的权重