add missing dependencies
This commit is contained in:
parent
103e73a15f
commit
605c946da2
1 changed files with 42 additions and 0 deletions
42
R/getAllFromCoord.R
Normal file
42
R/getAllFromCoord.R
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
# Define function
|
||||||
|
getAllFromCoord <- function(coord, start_date, end_date, allstations, N = 3, headers, base = "https://public-api.meteofrance.fr",btw_station_sleep = 1, within_statio_sleep=5,endpoint="public/DPClim/v1/") {
|
||||||
|
three_station = getIdFromCoords(coord, allstations, N = N)
|
||||||
|
alldata = lapply(three_station$Id_station, function(statid) {
|
||||||
|
print(paste("recuperer station", statid))
|
||||||
|
allstat = tryCatch(
|
||||||
|
getStationData(start_date = start_date, end_date = end_date, station_id = statid, headers = headers, base = base, timesleep=within_statio_sleep,dpclim=endpoint),
|
||||||
|
error = function(e) {print(e); NULL}
|
||||||
|
)
|
||||||
|
print(paste("done, sleep",btw_station_sleep,"sec"))
|
||||||
|
print(dim(allstat))
|
||||||
|
Sys.sleep(btw_station_sleep)
|
||||||
|
return(allstat)
|
||||||
|
})
|
||||||
|
|
||||||
|
alldata = do.call("rbind.data.frame", alldata)
|
||||||
|
ids = three_station$Nom_usuel
|
||||||
|
names(ids) = three_station$Id_station
|
||||||
|
cbind.data.frame(alldata, Nom_usuel = ids[as.character(alldata[,1])])
|
||||||
|
}
|
||||||
|
|
||||||
|
# Define function
|
||||||
|
getAllFromCoordDPObs <- function(coord, start_date, end_date, allstations, N = 3, headers, base = "https://public-api.meteofrance.fr",btw_station_sleep = 1, within_statio_sleep=5,endpoint="public/DPClim/v1/") {
|
||||||
|
three_station = getIdFromCoords(coord, allstations, N = N)
|
||||||
|
alldata = lapply(three_station$Id_station, function(statid) {
|
||||||
|
print(paste("recuperer station", statid))
|
||||||
|
allstat = tryCatch(
|
||||||
|
getStationDataDPObs(start_date = start_date, end_date = end_date, station_id = statid, headers = headers, base = base, timesleep=within_statio_sleep,dpclim=endpoint),
|
||||||
|
error = function(e) {print(e); NULL}
|
||||||
|
)
|
||||||
|
print(paste("done, sleep",btw_station_sleep,"sec"))
|
||||||
|
print(dim(allstat))
|
||||||
|
Sys.sleep(btw_station_sleep)
|
||||||
|
return(allstat)
|
||||||
|
})
|
||||||
|
|
||||||
|
alldata = do.call("rbind.data.frame", alldata)
|
||||||
|
ids = three_station$Nom_usuel
|
||||||
|
names(ids) = three_station$Id_station
|
||||||
|
cbind.data.frame(alldata, Nom_usuel = ids[as.character(alldata[,1])])
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in a new issue