从以下代码中获取此错误消息。
library(marmap)
bathy<- getNOAA.bathy(lon1 = 113, lon2 = 115, lat1 = 4, lat2 = 5,
resolution = 2)
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") : cannot open: HTTP status was '404 Not Found'
代码在其他所有场合都运行良好,所以想知道是否有人知道NOAA ETOPO1服务器是否已关闭?我已经通过电子邮件发送了服务器网站上的联系人,但也许有人在此期间有答案。
由于
答案 0 :(得分:1)
我刚尝试过,它对我来说很好。对于将来, 404 Not Found 错误意味着服务器http://www.wikiwand.com/en/HTTP_404无法找到该服务。我会再次尝试它再次发生的情况。他们的服务器可能暂时关闭。
要获取该函数正在使用的URL,您可以查看源代码,只需将其粘贴到浏览器中,添加您想要查看的参数,如果它对R或HTTP请求有问题本身(HTTP代码表明它无论如何都不是R问题,但这种方法对调试事物很有用)。
答案 1 :(得分:0)
刚刚更新我的建议;我注意到MARMAP v0.9.2现在已经针对服务器位置的这种变化进行了纠正并且工作正常。
来自NOAA的约翰回复了我。 getNOAA.bathy中使用的URL已经退休了一段时间。他建议我将以下修改后的网址替换成功能;getNOAA.bathy2<-
function (lon1, lon2, lat1, lat2, resolution = 4, keep = FALSE)
{
x1 = x2 = y1 = y2 = NULL
if (lon1 < lon2) {
x1 <- lon1
x2 <- lon2
}
else {
x2 <- lon1
x1 <- lon2
}
if (lat1 < lat2) {
y1 <- lat1
y2 <- lat2
}
else {
y2 <- lat1
y1 <- lat2
}
res = resolution * 0.0166666666666667
FILE <- paste("marmap_coord_", x1, ":", y1, ":", x2, ":",
y2, "_res_", resolution, ".csv", sep = "")
if (FILE %in% list.files()) {
cat("File already exists ; loading '", FILE, "'", sep = "")
exisiting.bathy <- read.bathy(FILE, header = T)
return(exisiting.bathy)
}
else {
WEB.REQUEST <- paste("http://maps.ngdc.noaa.gov/mapviewer-support/wcs-proxy/wcs.groovy?filename=etopo1.xyz&request=getcoverage&version=1.0.0&service=wcs&coverage=etopo1&CRS=EPSG:4326&format=xyz&resx=0.016666666666666667&resy=0.016666666666666667&bbox=-90.08789062497661,22.248428704378167,-79.07958984372954,31.877557643332576",
res, "&resy=", res, "&bbox=", x1, ",", y1, ",", x2,
",", y2, sep = "")
cat("Querying NOAA database ...\n")
cat("This may take seconds to minutes, depending on grid size\n")
bath <- read.table(WEB.REQUEST)
cat("Building bathy matrix ...\n")
bath2 <- as.bathy(bath)
if (keep == TRUE) {
write.table(bath, file = FILE, sep = ",", quote = FALSE,
row.names = FALSE)
}
return(bath2)
}
}