Afo*_*o_a 5 r openstreetmap osmar
我正在学习如何使用osmar包下载R中的OSM数据的教程,所以代码是:
library(osmar)
src <- osmsource_api()
bb <- center_bbox(174.76778, -36.85056, 700, 700)
ua <- get_osm(bb, source = src)
Run Code Online (Sandbox Code Playgroud)
当我运行最后一行时,会出现此错误:
我不确定这意味着什么.当我谷歌这个错误时,我只能看到与Bioconductor和biomaRt相关的东西,这与我正在工作的东西无关.但是,我认为这与R到OSM网站的连接有关(?).所以我想知道是否有人知道如何解决它的一些提示.谢谢!
mmd*_*mmd 10
您看到的错误消息是指服务器的以下响应.它基本上意味着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>
Run Code Online (Sandbox Code Playgroud)
一个简单的解决方法是使用HTTPS提供正确的URL:
src <- osmsource_api(url = "https://api.openstreetmap.org/api/0.6/")
Run Code Online (Sandbox Code Playgroud)
附注:OSM API(您正在使用的端点)仅用于编辑地图.因此,毕竟这可能违反了该服务的使用条款.更好地使用基于OSM镜像或Overpass API的一些替代方案.