Skip to content

Census geocoder single address error #168

Description

@lrsulli

Thank you for the great package!

I am running into an error using the single address method with the Census Geocoder which was not occurring before the Census recently updated their geocoder. The error message reads "Error: lexical error: invalid char in json text." I have tried to geocode the same list of addresses multiple times and the error occurs at different points in the list and sometimes not at all.

# Geocode addresses -------------------------------------------------------

# Generate counter to track progress
counter <- 0

# Get geocodes

data_geo <- lapply(split_list, function(x) {
    dt_geo <- geocode(
        .tbl = x,
        method = "census",
        mode = "single",
        street = "address",
        city = "city",
        state = "state",
        postalcode = "zip",
        full_results = TRUE,
        api_options = list(census_return_type = 'geographies')
        )
    
    # Check progress
    counter <<- counter + 1
    print(paste0('Progress: ', counter, ' of ', num_dt))

    return(dt_geo)
    })
#> Passing 1,000 addresses to the US Census single address geocoder
#> Warning in query_api(api_url, api_query_parameters, method = method): Bad
#> Request (HTTP 400).
#> Error: lexical error: invalid char in json text.
#>                                        <!DOCTYPE html PUBLIC "-//W3C//
#>                      (right here) ------^

Created on 2022-06-14 by the reprex package (v2.0.1)

Here is my session information for your reference:

  • Session info --------------------------------------------------------------------------
    setting value
    version R version 4.1.0 (2021-05-18)
    os Windows Server x64
    system x86_64, mingw32
    ui RStudio
    language (EN)
    collate English_United States.1252
    ctype English_United States.1252
    tz America/New_York
    date 2022-06-14

  • Packages ------------------------------------------------------------------------------
    ! package * version date lib source
    assertthat 0.2.1 2019-03-21 [2] CRAN (R 4.0.3)
    backports 1.2.1 2020-12-09 [2] CRAN (R 4.0.3)
    cachem 1.0.5 2021-05-15 [2] CRAN (R 4.0.5)
    callr 3.7.0 2021-04-20 [2] CRAN (R 4.0.5)
    cli 2.5.0 2021-04-26 [2] CRAN (R 4.0.5)
    clipr 0.7.1 2020-10-08 [2] CRAN (R 4.0.3)
    crayon 1.4.1 2021-02-08 [2] CRAN (R 4.0.4)
    curl 4.3.1 2021-04-30 [2] CRAN (R 4.0.5)
    data.table * 1.14.0 2021-02-21 [2] CRAN (R 4.0.4)
    DBI 1.1.1 2021-01-15 [2] CRAN (R 4.0.3)
    desc 1.3.0 2021-03-05 [2] CRAN (R 4.0.4)
    devtools 2.4.1 2021-05-05 [2] CRAN (R 4.0.5)
    digest 0.6.27 2020-10-24 [2] CRAN (R 4.0.3)
    dplyr 1.0.6 2021-05-05 [2] CRAN (R 4.0.5)
    ellipsis 0.3.2 2021-04-29 [2] CRAN (R 4.0.5)
    evaluate 0.14 2019-05-28 [2] CRAN (R 4.0.3)
    fansi 0.5.0 2021-05-25 [2] CRAN (R 4.0.5)
    fastmap 1.1.0 2021-01-25 [2] CRAN (R 4.0.3)
    forcats 0.5.1 2021-01-27 [2] CRAN (R 4.0.3)
    fs 1.5.0 2020-07-31 [2] CRAN (R 4.0.3)
    generics 0.1.0 2020-10-31 [2] CRAN (R 4.0.3)
    glue 1.4.2 2020-08-27 [2] CRAN (R 4.0.3)
    haven * 2.4.3 2021-08-04 [1] CRAN (R 4.1.1)
    highr 0.9 2021-04-16 [2] CRAN (R 4.0.5)
    hms 1.0.0 2021-01-13 [2] CRAN (R 4.0.3)
    htmltools 0.5.1.1 2021-01-22 [2] CRAN (R 4.0.3)
    httr 1.4.2 2020-07-20 [2] CRAN (R 4.0.3)
    jsonlite 1.7.2 2020-12-09 [2] CRAN (R 4.0.4)
    knitr 1.31 2021-01-27 [2] CRAN (R 4.0.3)
    lifecycle 1.0.0 2021-02-15 [2] CRAN (R 4.0.4)
    magrittr 2.0.1 2020-11-17 [2] CRAN (R 4.0.3)
    memoise 2.0.0 2021-01-26 [2] CRAN (R 4.0.3)
    pillar 1.6.1 2021-05-16 [2] CRAN (R 4.0.5)
    pkgbuild 1.2.0 2020-12-15 [2] CRAN (R 4.0.3)
    pkgconfig 2.0.3 2019-09-22 [2] CRAN (R 4.0.3)
    pkgload 1.2.1 2021-04-06 [2] CRAN (R 4.0.5)
    prettyunits 1.1.1 2020-01-24 [2] CRAN (R 4.0.3)
    processx 3.5.2 2021-04-30 [2] CRAN (R 4.0.5)
    progress 1.2.2 2019-05-16 [2] CRAN (R 4.0.3)
    ps 1.6.0 2021-02-28 [2] CRAN (R 4.0.4)
    purrr 0.3.4 2020-04-17 [2] CRAN (R 4.0.3)
    R6 2.5.0 2020-10-28 [2] CRAN (R 4.0.3)
    readr 1.4.0 2020-10-05 [2] CRAN (R 4.0.3)
    remotes 2.4.0 2021-06-02 [2] CRAN (R 4.0.2)
    reprex * 2.0.1 2021-08-05 [1] CRAN (R 4.1.3)
    rlang 0.4.11 2021-04-30 [2] CRAN (R 4.0.5)
    rmarkdown 2.8 2021-05-07 [2] CRAN (R 4.0.5)
    rprojroot 2.0.2 2020-11-15 [2] CRAN (R 4.0.3)
    rstudioapi 0.13 2020-11-12 [2] CRAN (R 4.0.3)
    sessioninfo 1.1.1 2018-11-05 [2] CRAN (R 4.0.3)
    styler 1.4.1 2021-03-30 [2] CRAN (R 4.0.4)
    testthat 3.0.2 2021-02-14 [2] CRAN (R 4.0.4)
    tibble 3.1.2 2021-05-16 [2] CRAN (R 4.0.5)
    tidygeocoder * 1.0.5 2021-11-02 [1] CRAN (R 4.1.3)
    tidyselect 1.1.0 2020-05-11 [2] CRAN (R 4.0.3)
    usethis 2.0.1 2021-02-10 [2] CRAN (R 4.0.4)
    utf8 1.2.1 2021-03-12 [2] CRAN (R 4.0.4)
    vctrs 0.3.8 2021-04-29 [2] CRAN (R 4.0.5)
    withr 2.4.2 2021-04-18 [2] CRAN (R 4.0.5)
    D xfun 0.19 2020-10-30 [2] CRAN (R 4.0.2)
    yaml 2.2.1 2020-02-01 [2] CRAN (R 4.0.3)

[1] \rschfs1x/userrs/K-Q/lrs263_RS/Documents/R/win-library/4.1
[2] C:/Program Files/R/R-4.1.0/library

D -- DLL MD5 mismatch, broken installation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions