-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
need hipaa compliant geocodio endpoint #137
Comments
Hi @groliver-pcci, yes we could add a |
Sounds good, I'll let you know when I have a branch ready for you to test. However, I'm not sure I'm following the issue you are running into. You should be able to just use the |
Just saw the api_url option which allows to function, but I don't quite under stand why the base geocodio wouldn't work
The initial problem I had without that was an error
rm_quote(deparse(substitute(address))) :
could not find function "rm_quote"
which is from the utils.r, I didn't manually load I suppose.
I had tried to just paste the URL into some helpers and see if it would work
get_geocodio_url <- function(api_v ='1.6', reverse = FALSE) {
# return API URL based on api version (ex. 1.6)
url_keyword <- if (reverse == TRUE) 'reverse' else 'geocode'
return(paste0("https://api-hipaa.geocod.io/v", as.character(api_v), "/", url_keyword))
}
get_api_url <- function(method, reverse = FALSE, return_type = 'locations',
search = 'onelineaddress', geocodio_v = 1.6, iq_region = 'us',
mapbox_permanent = FALSE, mapquest_open = FALSE) {
api_url <- switch(method,
"osm" = get_osm_url(reverse = reverse),
"census" = get_census_url(return_type, search),
"geocodio" = get_geocodio_url(geocodio_v, reverse = reverse),
"iq" = get_iq_url(iq_region, reverse = reverse),
"opencage" = get_opencage_url(), # same url as forward geocoding
"google" = get_google_url(), # same url as forward geocoding
"mapbox" = get_mapbox_url(mapbox_permanent), # same url as fwd geocoding
"here" = get_here_url(reverse = reverse),
"tomtom" = get_tomtom_url(reverse = reverse),
"mapquest" = get_mapquest_url(mapquest_open, reverse = reverse),
"bing" = get_bing_url(),
"arcgis" = get_arcgis_url(reverse = reverse),
"geoapify" = get_geoapify_url(reverse = reverse)
)
if (length(api_url) == 0) stop('API URL not found', call. = FALSE)
return(api_url)
}
#plugging in the api_url directly does seem to work
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(tidygeocoder)
library(tibble)
library(dplyr)
library(tidygeocoder)
address_single <- tibble(singlelineaddress = c(
"11 Wall St, NY, NY",
"600 Peachtree Street NE, Atlanta, Georgia"
))
address_components <- tribble(
~street, ~cty, ~st,
"11 Wall St", "NY", "NY",
"600 Peachtree Street NE", "Atlanta", "GA"
)
sample_addresses %>% slice(1:2) %>%
geocode(addr, method = 'geocodio')
#> Warning in query_api(api_url, query_parameters, mode = "list", input_list =
#> address_list, : Forbidden (HTTP 403).
#> Error: Can't subset columns that don't exist.
#> x Columns `lat` and `long` don't exist.
#geocodio
Sys.getenv("GEOCODIO_API_KEY")
#see if updated
#system curl works
system(paste("curl", paste0("https://api-hipaa.geocod.io/v1.6/geocode?q=Philadelphia&api_key=",
Sys.getenv("GEOCODIO_API_KEY"))))
#> [1] 0
osm_s1 <- geo(
address = address_single$singlelineaddress, method = "osm",
lat = latitude, long = longitude
)
#error In addition: Warning message:
# In query_api(api_url, query_parameters, mode = "list", input_list = address_list, :
# Forbidden (HTTP 403).
geo(
address = address_single$singlelineaddress, method = "geocodio",
lat = latitude, long = longitude
)
#> Warning in query_api(api_url, query_parameters, mode = "list", input_list =
#> address_list, : Forbidden (HTTP 403).
#> Error: Can't subset columns that don't exist.
#> x Columns `latitude` and `longitude` don't exist.
#works
geo(
address = address_single$singlelineaddress,
lat = latitude, long = longitude, method='geocodio',
api_url ="https://api-hipaa.geocod.io/v1.6/geocode" )
#> # A tibble: 2 x 3
#> address latitude longitude
#> <chr> <dbl> <dbl>
#> 1 11 Wall St, NY, NY 40.7 -74.0
#> 2 600 Peachtree Street NE, Atlanta, Georgia 33.8 -84.4
geo(
address = address_single$singlelineaddress,
lat = latitude, long = longitude, method='geocodio',geocodio_v ="1.6" )
#> Warning in query_api(api_url, query_parameters, mode = "list", input_list =
#> address_list, : Forbidden (HTTP 403).
#> Error: Can't subset columns that don't exist.
#> x Columns `latitude` and `longitude` don't exist.
From: Jesse Cambon ***@***.***>
Sent: Monday, September 20, 2021 10:53 AM
To: jessecambon/tidygeocoder ***@***.***>
Cc: George 'Holt' Oliver ***@***.***>; Mention ***@***.***>
Subject: Re: [jessecambon/tidygeocoder] need hipaa compliant geocodio endpoint (#137)
Sounds good, I'll let you know when I have a branch ready for you to test.
However, I'm not sure I'm following the issue you are running into. You should be able to just use the api_url parameter to specify the HIPAA endpoint without modifying the current tidygeocoder package code. If this isn't working, could you post a reprex? https://reprex.tidyverse.org/<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Freprex.tidyverse.org%2F&data=04%7C01%7Cgeorge.oliver%40pccinnovation.org%7Ca9c6e6f4b0e24a42a11408d97c4eabba%7C9a2a9ade704f4416b09447b8a504ad39%7C0%7C0%7C637677499607542058%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=ZX9L%2Bl4sR1hntYZwEHrIIsMFZDxkKsZIL1x2%2BX%2BL%2BfI%3D&reserved=0>
-
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.ghproxy.top%2Fjessecambon%2Ftidygeocoder%2Fissues%2F137%23issuecomment-923054265&data=04%7C01%7Cgeorge.oliver%40pccinnovation.org%7Ca9c6e6f4b0e24a42a11408d97c4eabba%7C9a2a9ade704f4416b09447b8a504ad39%7C0%7C0%7C637677499607552052%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=bUL%2BvYbLRGzOVxdN24Cpn6N1%2BFZu%2FiOBwAM1xUGjZmI%3D&reserved=0>, or unsubscribe<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.ghproxy.top%2Fnotifications%2Funsubscribe-auth%2FANJMAWJOFH3LMVXMB65O7O3UC5KELANCNFSM5EK7OYPQ&data=04%7C01%7Cgeorge.oliver%40pccinnovation.org%7Ca9c6e6f4b0e24a42a11408d97c4eabba%7C9a2a9ade704f4416b09447b8a504ad39%7C0%7C0%7C637677499607552052%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=HIEQn%2BwJDH6dygEs4w244xX3FmT30joUPGstPvTLBYk%3D&reserved=0>.
Triage notifications on the go with GitHub Mobile for iOS<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7Cgeorge.oliver%40pccinnovation.org%7Ca9c6e6f4b0e24a42a11408d97c4eabba%7C9a2a9ade704f4416b09447b8a504ad39%7C0%7C0%7C637677499607562043%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=N5Mgds2GS14g4YAKVSBfHicOCx1QYClRrKv7Bsxie%2Fc%3D&reserved=0> or Android<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26referrer%3Dutm_campaign%253Dnotification-email%2526utm_medium%253Demail%2526utm_source%253Dgithub&data=04%7C01%7Cgeorge.oliver%40pccinnovation.org%7Ca9c6e6f4b0e24a42a11408d97c4eabba%7C9a2a9ade704f4416b09447b8a504ad39%7C0%7C0%7C637677499607562043%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=5CG6rk6u9ybDoALZbLMUM6U3AqDGw4YAdfLn1itOpFQ%3D&reserved=0>.
|
I see, I typically click the In any case, I have a branch ready for you to try. You can install it with this command: devtools::install_github("jessecambon/tidygeocoder", ref = "geocodio-hipaa") After that installs you should be able to use the library(tidygeocoder)
results <- geo(address = "Toronto", method = 'geocodio', geocodio_hipaa = TRUE, verbose = TRUE) Let me know if you run into any issues. |
Since it is possible to query the HIPAA geocod.io API with the library(tidygeocoder)
library(purrr)
address <- "600 Peachtree Street NE, Atlanta, GA"
# Query to the main geocod.io API
geo(address, method = "geocodio", verbose = TRUE)
#> Number of Unique Addresses: 1
#> Querying API URL: https://api.geocod.io/v1.6/geocode
#> Passing the following parameters to the API:
#> q : "600 Peachtree Street NE, Atlanta, GA"
#> api_key : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
#> limit : "1"
#> HTTP Status Code: 200
#> Query completed in: 1 seconds
#>
#> # A tibble: 1 x 3
#> address lat long
#> <chr> <dbl> <dbl>
#> 1 600 Peachtree Street NE, Atlanta, GA 33.8 -84.4
# use purrr:partial to build a custom geo() function.
hipaa_geo <- partial(geo, method = "geocodio", api_url = "https://api-hipaa.geocod.io/v1.6/geocode")
# hipaa_geo() works just like geo(method = "geocodio", api_url = "https://api-hipaa.geocod.io/v1.6/geocode") would
# The query fails here, because I don't have a key for the HIPAA geocod.io API,
# which is different from the main geocod.io key
hipaa_geo(address, verbose = TRUE)
#> Number of Unique Addresses: 1
#> Querying API URL: https://api-hipaa.geocod.io/v1.6/geocode
#> Passing the following parameters to the API:
#> q : "600 Peachtree Street NE, Atlanta, GA"
#> api_key : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
#> limit : "1"
#> Warning in query_api(api_url, api_query_parameters, method = method): Forbidden
#> (HTTP 403).
#> HTTP Status Code: 403
#> Error: Invalid API key
#> Query completed in: 0.5 seconds
#>
#> # A tibble: 1 x 3
#> address lat long
#> <chr> <dbl> <dbl>
#> 1 600 Peachtree Street NE, Atlanta, GA NA NA Maybe we should advertise the purrr::partial approach a bit for this use-case. Session infosessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#> setting value
#> version R version 4.1.1 (2021-08-10)
#> os Windows 10 x64
#> system x86_64, mingw32
#> ui RTerm
#> language en
#> collate German_Germany.1252
#> ctype German_Germany.1252
#> tz Europe/Berlin
#> date 2021-09-29
#>
#> - Packages -------------------------------------------------------------------
#> package * version date lib source
#> assertthat 0.2.1 2019-03-21 [1] standard (@0.2.1)
#> backports 1.2.1 2020-12-09 [1] standard (@1.2.1)
#> cli 3.0.1 2021-07-17 [1] standard (@3.0.1)
#> crayon 1.4.1 2021-02-08 [1] standard (@1.4.1)
#> curl 4.3.2 2021-06-23 [1] standard (@4.3.2)
#> DBI 1.1.1 2021-01-15 [1] standard (@1.1.1)
#> digest 0.6.27 2020-10-24 [1] standard (@0.6.27)
#> dplyr 1.0.7 2021-06-18 [1] standard (@1.0.7)
#> ellipsis 0.3.2 2021-04-29 [1] standard (@0.3.2)
#> evaluate 0.14 2019-05-28 [1] standard (@0.14)
#> fansi 0.5.0 2021-05-25 [1] standard (@0.5.0)
#> fastmap 1.1.0 2021-01-25 [1] standard (@1.1.0)
#> fs 1.5.0 2020-07-31 [1] standard (@1.5.0)
#> generics 0.1.0 2020-10-31 [1] standard (@0.1.0)
#> glue 1.4.2 2020-08-27 [1] standard (@1.4.2)
#> highr 0.9 2021-04-16 [1] standard (@0.9)
#> htmltools 0.5.2 2021-08-25 [1] CRAN (R 4.1.1)
#> httr 1.4.2 2020-07-20 [1] standard (@1.4.2)
#> jsonlite 1.7.2 2020-12-09 [1] standard (@1.7.2)
#> knitr 1.34 2021-09-09 [1] standard (@1.34)
#> lifecycle 1.0.0 2021-02-15 [1] standard (@1.0.0)
#> magrittr 2.0.1 2020-11-17 [1] standard (@2.0.1)
#> pillar 1.6.2 2021-07-29 [1] standard (@1.6.2)
#> pkgconfig 2.0.3 2019-09-22 [1] standard (@2.0.3)
#> purrr * 0.3.4 2020-04-17 [1] standard (@0.3.4)
#> R6 2.5.1 2021-08-19 [1] standard (@2.5.1)
#> reprex 2.0.1 2021-08-05 [1] standard (@2.0.1)
#> rlang 0.4.11 2021-04-30 [1] standard (@0.4.11)
#> rmarkdown 2.11 2021-09-14 [1] standard (@2.11)
#> rstudioapi 0.13 2020-11-12 [1] standard (@0.13)
#> sessioninfo 1.1.1 2018-11-05 [1] standard (@1.1.1)
#> stringi 1.7.4 2021-08-25 [1] CRAN (R 4.1.1)
#> stringr 1.4.0 2019-02-10 [1] standard (@1.4.0)
#> styler 1.6.1 2021-09-17 [1] standard (@1.6.1)
#> tibble 3.1.4 2021-08-25 [1] standard (@3.1.4)
#> tidygeocoder * 1.0.3 2021-04-19 [1] standard (@1.0.3)
#> tidyselect 1.1.1 2021-04-30 [1] standard (@1.1.1)
#> utf8 1.2.2 2021-07-24 [1] standard (@1.2.2)
#> vctrs 0.3.8 2021-04-29 [1] standard (@0.3.8)
#> withr 2.4.2 2021-04-18 [1] standard (@2.4.2)
#> xfun 0.26 2021-09-14 [1] standard (@0.26)
#> yaml 2.2.1 2020-02-01 [1] standard (@2.2.1)
#>
#> [1] C:/Users/Daniel.AK-HAMBURG/Documents/R/win-library/4.1
#> [2] C:/Program Files/R/R-4.1.1/library |
@dpprdan that's a nice approach for customizing the API endpoint that we could offer. In geo(address = 'Seoul', method = 'geocodio', api_options = list(geocodio_v = 1.6, geocodio_hipaa = TRUE)) This would allow us to accommodate some API endpoint customization shortcuts while reducing the number of parameters in |
The |
geocodio service has a separate hipaa compliant endpoint, access is restricted to this address only.
Can future release add a geocodio-hipaa, flag or api-url alias
in
api_url
"geocodio" = get_geocodio_url(geocodio_v, reverse = reverse , hipaa= F),
or
get_geocodio_hipaa_url <- function(api_v ='1.6', reverse = FALSE) {
return API URL based on api version (ex. 1.6)
url_keyword <- if (reverse == TRUE) 'reverse' else 'geocode'
return(paste0("https://api-hipaa.geocod.io/v", as.character(api_v), "/", url_keyword))
}
The text was updated successfully, but these errors were encountered: