Skip to content
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

Issue with custom_query and geocodio #48

Closed
MikeBurkePhD opened this issue Oct 2, 2020 · 4 comments
Closed

Issue with custom_query and geocodio #48

MikeBurkePhD opened this issue Oct 2, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@MikeBurkePhD
Copy link

MikeBurkePhD commented Oct 2, 2020

First, thank you for the excellent package.

I am running into an issue where custom_query won't pull the requested fields from the geocodio API.

Reproducible example requesting state legislative districts or Census tracts via the field keys stateleg and tract_code:


library(tidygeocoder)
library(tidyverse)

Sys.setenv(GEOCODIO_API_KEY = "INSERT YOUR KEY")

some_addresses <- tribble(
                       ~name,                  ~addr,
                       "White House",          "1600 Pennsylvania Ave, Washington, DC",
                       "Transamerica Pyramid", "600 Montgomery St, San Francisco, CA 94111",     
                       "Willis Tower",         "233 S Wacker Dr, Chicago, IL 60606"                                  
                       )

test <- some_addresses %>% geocode(
                                addr, method = "geocodio", 
                                full_results = TRUE,
                                custom_query = list(fields = 'stateleg')
                                )

test2 <- some_addresses %>% geocode(
                                 addr, method = "geocodio", 
                                 full_results = TRUE,
                                 custom_query = list(fields = 'tract_code')
                                 )

My expectation was that this would give me the information contained within the stateleg and tract_code keys from geocodio. This is the link to the relevent API documentaiton: https://www.geocod.io/docs/?shell#fields.

I modeled this off the example in the tidygeocoder documentation for getting different vintages of census data (i.e., list(vintage = 'Current_Census2010').

jessecambon added a commit that referenced this issue Oct 2, 2020
@jessecambon
Copy link
Owner

jessecambon commented Oct 2, 2020

Thanks for reporting this. It looks like there was a simple oversight in the batch geocodio function (the custom_query argument just wasn't being passed). I put the fix on a separate branch and you can install it with this:

devtools::install_github("jessecambon/tidygeocoder", ref = 'fix/geocodio-batch-custom')

Hopefully that makes everything work as expected.

You should be able to replicate the query you linked to with one function call like this:

test <- some_addresses %>% geocode(
  addr, method = "geocodio", 
  full_results = TRUE,
  custom_query = list(fields = 'stateleg,cd')
)

@jessecambon jessecambon added the bug Something isn't working label Oct 2, 2020
@MikeBurkePhD
Copy link
Author

Yes, this is working perfectly now. Thanks for the update and quick reply! I really appreciate it.

Also, in case anyone is interested, here is an example of how to get the full FIPS information using 2019 Census information (including census tract, block, etc):

test2 <- some_addresses %>% geocode(
                                 addr, method = "geocodio", 
                                 full_results = TRUE,
                                 custom_query = list(fields = 'census2019, full_fips')

@ALFerino
Copy link

Hi jessecambon,
I am having a similar issue with custom_query but looking for Congressional District information.

Is the fix above for MikeBurkePhD in the current tidygeocoder package or do i need a separate download?

Any help is much appreciated!

@jessecambon
Copy link
Owner

@ALFerino this fix is in the GitHub/development version of the package (master branch), but not the CRAN version yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants