You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes hereR::isoline fails for specific cases in poi, causing an error. Consider adding a robust argument that allows the function to return values for the successful isolines and NAs for the unsuccessful ones. This argument would take a logical and default to FALSE.
I often find myself using this pattern:
library(dplyr)
library(hereR)
library(purrr)
library(tidyr)
# Failproof version of isoline (returns just the geometry for use in mutate).safely_isoline<-function(...) {
fxn<- safely(isoline)
value<- fxn(...)
if (is.null(value$error)) value$result$geometryelseNA
}
# A sf object with points.my_sf<-...# Example usage: Replace some point geometries with isoline geometries.my_sf %>%
group_by(id) %>% # Some unique identifier.
nest(data=geometry) %>% # A sfc with point geometries.
mutate(geometry= map(data, safely_isoline)) %>%
select(-data) %>% unnest(geometry) %>%
ungroup()
The failing cases may deserve a bug report of their own. I haven't figured out the cause; all I know is that it seems to happen for specific cases when combined with specific function arguments. This issue is only concerned with moving past these failures.
The text was updated successfully, but these errors were encountered:
Unfortunately I don't quite understand the requested feature, and therefore try to narrow it down to two cases:
If a request fails on the API side (response status is not 200), then the response is completely ignored (NULL) by hereR::isoline. So for this request, the rows with this id will be missing in the return value.
Or is it an error that occurs within the function hereR::isoline? That means the request to the HERE API was successful, but something in the processing of the response from the API into an sf object fails.
In the first case the option with a boolean robust argument seems to be a reasonable option, which would replace the missing rows (NULL) with a row where every value is NA, except from the request id. In the second case we should rather try to fix the error in the function. If it is the second case, do you have a reproducible example? In your example code POIs are missing, which trigger this error.
Sometimes
hereR::isoline
fails for specific cases inpoi
, causing an error. Consider adding arobust
argument that allows the function to return values for the successful isolines and NAs for the unsuccessful ones. This argument would take a logical and default to FALSE.I often find myself using this pattern:
The failing cases may deserve a bug report of their own. I haven't figured out the cause; all I know is that it seems to happen for specific cases when combined with specific function arguments. This issue is only concerned with moving past these failures.
The text was updated successfully, but these errors were encountered: