Closed technocrat closed 1 year ago
I noticed that traffic flow API v6 is on maintenance. While they have API v7 for traffic flow. Looked like hereR
haven't used the API v7, have it?
Thanks, I’ll check back next week if I see that v6 is back up and report back.On Jul 3, 2023, at 9:08 PM, said @.***> wrote: I noticed that traffic flow API v6 is on maintenance. While they have API v7 for traffic flow. Looked like hereR haven't used the API v7, have it?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>
Thanks for reporting, the issue you're experiencing is likely caused by an invalid API key.
Go to the projects view on HERE developer. Then create a new project and select REST. There you should be able to create an API key using the button “Create API key”. Copy paste the key and set it using set_key(...)
. Or alternatively export it to the environment export HERE_API_KEY=<YOUR-VALID-KEY-HERE>
.
# libraries
library(dplyr)
library(sf)
#> Linking to GEOS 3.10.2, GDAL 3.4.2, PROJ 8.2.1; sf_use_s2() is TRUE
library(hereR)
# use a valid key
# set_key("<KEY>")
# print some logs
set_verbose(TRUE)
# health facility
data <- read.csv("https://raw.githubusercontent.com/isaid-hi/bipi.datalab/main/2023.06.24_%234%20Hospital%20Access/hospitals.csv")
# hospital only
hospitals <- data |> filter(Type %in% "Rumah Sakit")
hospital_sf <- st_as_sf(
x = hospitals,
coords = c("Longitude", "Latitude"),
crs = 4326
)
# isoline for hospitals
isochrones_all <- isoline(
poi = hospital_sf,
range = seq(10, 30, 10) * 60,
range_type = "time",
datetime <- as.POSIXct(paste0(Sys.Date(), " 10:00"))
)
#> Sending 2 request(s) with 1 RPS to: 'https://isoline.router.hereapi.com/v8/isolines?...'
#> Received 2 response(s) with total size: 11.7 Kb
# sort descending, convert units
isochrones_all <- isochrones_all |>
arrange(desc(range)) |>
mutate(name = paste0((range - 600) / 60, " to ", range / 60, " mins"))
isochrones_all
#> Simple feature collection with 6 features and 6 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: 106.713 ymin: -6.876068 xmax: 106.9547 ymax: -6.421509
#> Geodetic CRS: WGS 84
#> id rank departure arrival range
#> 1 1 3 2023-07-04 10:00:00 2023-07-04 10:30:00 1800
#> 2 2 3 2023-07-04 10:00:00 2023-07-04 10:30:00 1800
#> 3 1 2 2023-07-04 10:00:00 2023-07-04 10:20:00 1200
#> 4 2 2 2023-07-04 10:00:00 2023-07-04 10:20:00 1200
#> 5 1 1 2023-07-04 10:00:00 2023-07-04 10:10:00 600
#> 6 2 1 2023-07-04 10:00:00 2023-07-04 10:10:00 600
#> geometry name
#> 1 POLYGON ((106.762 -6.558151... 20 to 30 mins
#> 2 POLYGON ((106.7142 -6.79332... 20 to 30 mins
#> 3 POLYGON ((106.7978 -6.73667... 10 to 20 mins
#> 4 POLYGON ((106.7334 -6.77410... 10 to 20 mins
#> 5 POLYGON ((106.8314 -6.60003... 0 to 10 mins
#> 6 POLYGON ((106.7639 -6.77581... 0 to 10 mins
mapview::mapview(isochrones_all, zcol = "name")
I hope this helps?
Thanks for the response. Actually this potential bug starts here in Posit Community.
The original issue is not the isoline
function, but the flow
function.
With the exact same API key, isoline
as the code above was working perfectly. But the flow
function not.
library(hereR)
set_key(here_api_key)
flow(aoi, min_jam_factor = 0, url_only = FALSE)
it return error like this
Warning messages:
1: In .parse_response(i, out$responses()[[i]]) :
https://traffic.ls.hereapi.com/traffic/6.2/flow.json: Request 'id = 1' failed.
Status 403; Forbidden; Request forbidden -- authorization will not help.
2: In .parse_response(i, out$responses()[[i]]) :
https://traffic.ls.hereapi.com/traffic/6.2/flow.json: Request 'id = 2' failed.
Status 403; Forbidden; Request forbidden -- authorization will not help.
Thanks. I think I may have gone off into the wilderness when creating the project because I never saw an API key option. I’ll report back.On Jul 4, 2023, at 4:31 AM, Merlin Unterfinger @.***> wrote:
Thanks for reporting, the issue you're experiencing is likely caused by an invalid API key.
Go to the projects view on HERE developer. Then create a new project and select REST. There you should be able to create an API key using the button “Create API key”. Copy paste the key and set it using set_key(...). Or alternatively export it to the environment export HERE_API_KEY=
library(dplyr) library(sf)
library(hereR)
set_verbose(TRUE)
data <- read.csv("https://raw.githubusercontent.com/isaid-hi/bipi.datalab/main/2023.06.24_%234%20Hospital%20Access/hospitals.csv")
hospitals <- data |> filter(Type %in% "Rumah Sakit") hospital_sf <- st_as_sf( x = hospitals, coords = c("Longitude", "Latitude"), crs = 4326 )
isochrones_all <- isoline( poi = hospital_sf, range = seq(10, 30, 10) * 60, range_type = "time", datetime <- as.POSIXct(paste0(Sys.Date(), " 10:00")) )
isochrones_all <- isochrones_all |> arrange(desc(range)) |> mutate(name = paste0((range - 600) / 60, " to ", range / 60, " mins"))
isochrones_all
mapview::mapview(isochrones_all, zcol = "name")
I hope this helps?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>
Still no success. The documents suggested that an API Access key, as opposed to an OA token would be available by signing up for fremium, and that created fremium app but still only the option to create an OA token, which doesn't work, But then it appears that applications needed to be migrated from the old deveoper.here.com to the new platform.here.com, which requires a separate account. And then after signing into the platform account links to documentation go back to the ifi. In any event, not one of the OA tokens work and there's a different way to create a different kind of token, called API
I'm stumped. The return from flow()
doesn't pass access either.
I'm sure that {hereR}
will work well once the credentials can be satisfied, but I'm going to give it a rest for now.
I'm actually still waiting for Munterfi's response regarding the error in flow
function. Have you test it @munterfi ?
Note that the same API Key
works for isoline
but not for flow
fuction.
For clearer case, I move to the new issue #158
Sorry for the late reply, I was off some days.
HERE has introduced the HERE Platform as a successor to HERE Developer. The process to create an API key has changed slightly and differs from the description in the hereR package vignette:
hereR::set_key()
Describe the bug here endpoint rejects API key
Unless I am wrong that the 'single-bearer credential' is the API key, authentication is consistently failing. If the API key is something other than here.access.key.id or here.access.key.secret, that's unclear in the example given. I've been unable to discover a third way of creating tokens on their developer website.
Reproducible example
Expected behavior Following `set_key("some_token") request silently authenticates and returns results
Optionally: R session info Not relevant