Skip to contents

Match an addr vector to TIGER street ranges

Usage

addr_match_tiger_street_ranges(
  x,
  county = "39061",
  year = "2022",
  street_only_match = c("none", "all", "closest"),
  summarize = c("none", "union", "centroid")
)

Arguments

x

an addr vector to match

county

character string of county identifier

year

year of tigris product

street_only_match

for addresses that match a TIGER street name, but have street numbers that don't intersect with ranges of potential street numbers, return "none", "all", or the "closest" range geographies

summarize

optionally summarize matched street ranges as their union or centroid

Value

a list of matched tigris street range tibbles; a NULL value indicates that no street name was matched; if street_only_match is FALSE, a street range tibble with zero rows indicates that although a street was matched, there was no range containing the street number

Examples

my_addr <- as_addr(c("224 Woolper Ave", "3333 Burnet Ave", "33333 Burnet Ave", "609 Walnut St"))

addr_match_tiger_street_ranges(my_addr, county = "39061", street_only_match = "all")
#> $`224 Woolper Avenue`
#> # A tibble: 1 × 4
#>   TLID      s2_geography                                              from    to
#>   <chr>     <s2_geography>                                           <dbl> <dbl>
#> 1 103924294 LINESTRING (-84.511197 39.149684, -84.511752 39.149788,…   100   299
#> 
#> $`3333 Burnet Avenue`
#> # A tibble: 2 × 4
#>   TLID      s2_geography                                            from    to
#>   <chr>     <s2_geography>                                         <dbl> <dbl>
#> 1 103925697 LINESTRING (-84.500403 39.14089, -84.500289 39.141892)  3301  3399
#> 2 103925699 LINESTRING (-84.500525 39.139737, -84.500403 39.14089)  3247  3398
#> 
#> $`33333 Burnet Avenue`
#> # A tibble: 20 × 4
#>    TLID      s2_geography                                             from    to
#>    <chr>     <s2_geography>                                          <dbl> <dbl>
#>  1 103925448 LINESTRING (-84.499935 39.145118, -84.499813 39.146256)  3500  3599
#>  2 103925451 LINESTRING (-84.50004 39.144148, -84.499935 39.145118)   3401  3499
#>  3 103925453 LINESTRING (-84.500084 39.143783, -84.50004 39.144148)   3432  3466
#>  4 103925455 LINESTRING (-84.500181 39.142878, -84.500084 39.143783)  3400  3430
#>  5 103925697 LINESTRING (-84.500403 39.14089, -84.500289 39.141892)   3301  3399
#>  6 103925699 LINESTRING (-84.500525 39.139737, -84.500403 39.14089)   3247  3398
#>  7 103925700 LINESTRING (-84.500652 39.138641, -84.500525 39.139737)  3235  3298
#>  8 103925701 LINESTRING (-84.500867 39.136617, -84.500666 39.13853)   3200  3234
#>  9 103925703 LINESTRING (-84.500918 39.136124, -84.500867 39.136617)  3100  3199
#> 10 103971004 LINESTRING (-84.50102 39.135173, -84.500943 39.135883)   3101  3117
#> 11 103925748 LINESTRING (-84.501259 39.133087, -84.50102 39.135173)   2900  3099
#> 12 103965385 LINESTRING (-84.501494 39.130948, -84.501314 39.132613)  2800  2899
#> 13 103925898 LINESTRING (-84.501709 39.128975, -84.501494 39.130948)  2600  2799
#> 14 103925900 LINESTRING (-84.501777 39.128388, -84.501709 39.128975)  2601  2621
#> 15 103925902 LINESTRING (-84.50188 39.12747, -84.501777 39.128388)    2550  2598
#> 16 103925903 LINESTRING (-84.501832 39.126684, -84.501914 39.127034…  2500  2599
#> 17 103925914 LINESTRING (-84.502386 39.122796, -84.502278 39.123766)  2300  2399
#> 18 103925934 LINESTRING (-84.502601 39.120814, -84.502386 39.122796)  2200  2299
#> 19 103925937 LINESTRING (-84.502931 39.117861, -84.502601 39.120814)  2000  2199
#> 20 103925750 LINESTRING (-84.501314 39.132613, -84.501259 39.133087)  2901  2999
#> 
#> $`609 Walnut Street`
#> NULL
#> 

addr_match_tiger_street_ranges(my_addr, county = "39061", summarize = "centroid")
#> $`224 Woolper Avenue`
#> # A tibble: 1 × 4
#>   TLID      s2_geography                    from    to
#>   <chr>     <s2_geography>                 <dbl> <dbl>
#> 1 103924294 POINT (-84.5148163 39.1499943)   100   299
#> 
#> $`3333 Burnet Avenue`
#> # A tibble: 1 × 4
#>   TLID                s2_geography                    from    to
#>   <chr>               <s2_geography>                 <dbl> <dbl>
#> 1 103925697-103925699 POINT (-84.5004091 39.1408146)  3247  3399
#> 
#> $`33333 Burnet Avenue`
#> # A tibble: 0 × 4
#> # ℹ 4 variables: TLID <chr>, s2_geography <s2_geography>, from <dbl>, to <dbl>
#> 
#> $`609 Walnut Street`
#> NULL
#> 

addr_match_tiger_street_ranges(my_addr, county = "39061",
                               street_only_match = "closest", summarize = "centroid") |>
  dplyr::bind_rows() |>
  dplyr::mutate(census_bg_id = s2_join_tiger_bg(s2::as_s2_cell(s2_geography)))
#> # A tibble: 3 × 5
#>   TLID                s2_geography                    from    to census_bg_id
#>   <chr>               <s2_geography>                 <dbl> <dbl> <chr>       
#> 1 103924294           POINT (-84.5148163 39.1499943)   100   299 390610070002
#> 2 103925697-103925699 POINT (-84.5004091 39.1408146)  3247  3399 390610270002
#> 3 103925448           POINT (-84.499874 39.145687)    3500  3599 390610068002