osmar::get_osm() 下载 OSM 数据失败时出错:SYSTEM 或 PUBLIC,URI 丢失 [英] Error in osmar::get_osm() downloading OSM data fails: SYSTEM or PUBLIC, the URI is missing

查看:123
本文介绍了osmar::get_osm() 下载 OSM 数据失败时出错:SYSTEM 或 PUBLIC,URI 丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注 教程关于如何用osmar包下载R中的OSM数据,所以代码是:

I was following a tutorial on how to download OSM data in R with osmar package, so the code is:

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

当我运行最后一行时,出现此错误:

When I run this last line, this error appears:

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 网站的连接有关(?).所以我想知道是否有人知道如何解决它的一些技巧.谢谢!

I am not sure what this means. When I google this error, I can only see stuff related to Bioconductor, and biomaRt, which has nothing to do with what I am working. However, I believe that this has something to do with the connection with R to OSM website (?). So I'm wondering if anyone knows some tips on how to fix it. Thanks!

推荐答案

您看到的错误消息是指来自服务器的以下响应.这基本上意味着 osmar 包正在尝试通过 HTTP 下载,但服务器将您重定向到 HTTPS 位置.出于某种原因,osmar 没有遵循此重定向并失败.您可能应该将此问题报告给软件包所有者以修复它.

The error message you're seeing refers to the following response from the server. It basically means that the osmar package is trying to download via HTTP, but the server redirects you to the HTTPS location instead. For some reason osmar doesn't follow this redirect and fails. You should probably report this issue to the package owner to have it fixed.

<!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:

One easy fix would be to provide the proper URL with HTTPS:

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

旁注:OSM API(即您正在使用的端点)用于编辑地图.所以毕竟这可能违反了该服务的使用条款.最好使用一些基于 OSM 镜像或 Overpass API 的替代方案.

Side note: the OSM API (that's the endpoint you're using) is only meant to edit the map. So after all this might be violating the terms of usage of that service. Better use some alternatives based on OSM mirrors, or Overpass API.

这篇关于osmar::get_osm() 下载 OSM 数据失败时出错:SYSTEM 或 PUBLIC,URI 丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆