Skip to contents

Program Overview

According to (US Department of Housing and Urban Development, n.d.), the difficulty of linking United States Postal Service (USPS) ZIP codes to Census Bureau regions is one of the many obstacles that social science scholars and practitioners face. Only at the ZIP code level is there relevant data that, when paired with demographic data calculated at various Census geographic levels, could open up new paths of investigation.

Furthermore, the (US Department of Housing and Urban Development, n.d.) believes that while there are several appropriate approaches for integrating ZIP codes with Census geographies, they are limited. The HUD-USPS Crosswalk Files were supplied by PD&R to enable more routes for integrating these data. These one-of-a-kind files were created using data from the quarterly USPS Vacancy Data. They come straight from the USPS; they’re updated quarterly, so they’re always up to date with changes in ZIP code configurations; and they reflect both commercial and residential addresses. Because many of the phenomena that housing researchers study are based on housing unit or address, the latter attribute is of special interest to them. Analysts can take into account not just the spatial distribution of population, but also the spatial distribution of residences, by utilizing an allocation approach based on residential addresses rather than by area or population. This allows for a more sophisticated approach to data allocation across different geographies.

These journal articles describe the problem and proposed solution in more detail:


Wilson, Ron and Din, Alexander, 2018. “Understanding and Enhancing the U.S.
        Department of Housing and Urban Development’s ZIP Code Crosswalk Files,”
        Cityscape: A Journal of Policy Development and Research, Volume 20 Number 2, 277
        https://www.huduser.gov/portal/periodicals/cityscpe/vol20num2/ch16.pdf


Din, Alexander and Wilson, Ron, 2020. “Crosswalking ZIP Codes to Census
        Geographies: Geoprocessing the U.S. Department of Housing & Urban Development’s
        ZIP Code Crosswalk Files,” Cityscape: A Journal of Policy Development and
        Research, Volume 22, Number 1,
        https://www.huduser.gov/portal/periodicals/cityscpe/vol22num1/ch12.pdf


Census Geographies

This chart provided by the US Census Bureau gives a good example of the relationships among different geographies. The crosswalk files only support a subset of these.


Examples

There are 12 main function calls for the crosswalk files: the package also contains an omni function which encapsulates the capabilities of all the main function calls below – omni-function

  1. zip-tract
  2. zip-county
  3. zip-cbsa (Core Base Statistical Areas)
  4. zip-cbsadiv (Available 4th Quarter 2017 onwards)
  5. zip-cd (Congressional District)
  6. tract-zip
  7. county-zip
  8. cbsa-zip
  9. cbsadiv-zip (Available 4th Quarter 2017 onwards)
  10. cd-zip
  11. zip-countysub (Available 2nd Quarter 2018 onwards)
  12. countysub-zip (Available 2nd Quarter 2018 onwards)

The first geoid type in the function call is what to query for. For example in 1) above, ‘zip’ is the first geoid and ‘tract’ is the second geoid.

The second geoid in the function call describes the geoid which we want to determine ‘intersection’ with the first geoid where intersection is described as the % of residential, business, other, and total buildings that overlap.

For example, in function call #7, we might have a county called 22031 which has zip codes 71052, 71078, 71049, 71032 … where the residential % (res_ratio) of each zip is 0.38, 0.21, 0.11, 0.05 … respectively. Of all these zipcodes’ res_ratios, when added up will equal 1, signaling these grouping of zip codes make up 100% of residential address in the county with each zipcode taking up their respective residential percentage.

Disclaimer: Although there exists inverse relationships in the Crosswalk Files, the measurements are NOT COMPLETELY inverse – for reasons stated within the papers above.

These are basic examples which shows you to query the Crosswalk API. Before looking at the outputted data I RECOMMEND first taking a look at the parameters as well as return data located at the bottom of the page.

Crosswalk zipcode to census tract
library(rhud)
options (digits=4)

hud_cw_zip_tract(zip = '35213', year = c('2010'), quarter = c('1'))
#> 
#>     zip       tract res_ratio bus_ratio oth_ratio tot_ratio year quarter
#> 1 35213 01073010801  0.338469  0.404558  0.697872  0.354414 2010       1
#> 2 35213 01073010803  0.230782  0.028490  0.008511  0.212530 2010       1
#> 3 35213 01073005600  0.185858  0.039886  0.004255  0.171949 2010       1
#> 4 35213 01073010802  0.114337  0.011396  0.000000  0.105006 2010       1
#> 5 35213 01073002306  0.061953  0.509971  0.144681  0.088122 2010       1
#> 6 35213 01073004702  0.037626  0.000000  0.144681  0.039396 2010       1
#> 7 35213 01073004800  0.018975  0.000000  0.000000  0.017328 2010       1
#> 8 35213 01073010805  0.009244  0.005698  0.000000  0.008738 2010       1
#> 9 35213 01073010804  0.002757  0.000000  0.000000  0.002518 2010       1


Crosswalk zipcode to county fip
hud_cw_zip_county(zip = 35213, year = c('2020'), quarter = c('2'))
#> 
#>     zip county res_ratio bus_ratio oth_ratio tot_ratio year quarter
#> 1 35213  01073         1         1         1         1 2020       2


Crosswalk zipcode to core base statistical area (cbsa)
hud_cw_zip_cbsa(zip = 35213, year = c('2011'), quarter = c('3'))
#> 
#>     zip  cbsa res_ratio bus_ratio oth_ratio tot_ratio year quarter
#> 1 35213 13820         1         1         1         1 2011       3


Crosswalk zipcode to core based statistical area division (cbsadiv)
hud_cw_zip_cbsadiv(zip = '22031', year = c('2019'), quarter = c('4'))
#> 
#>     zip cbsadiv res_ratio bus_ratio oth_ratio tot_ratio year quarter
#> 1 22031   47894         1         1         1         1 2019       4


Crosswalk zipcode to congressional district (cd)
hud_cw_zip_cd(zip = '35213', year = c(2011), quarter = c(1))
#> 
#>     zip   cd res_ratio bus_ratio oth_ratio tot_ratio year quarter
#> 1 35213 0106  0.952728    0.9831  0.991701  0.955706 2011       1
#> 2 35213 0107  0.043711    0.0169  0.008299  0.041045 2011       1
#> 3 35213 0103  0.001781    0.0000  0.000000  0.001624 2011       1
#> 4 35213 0104  0.001781    0.0000  0.000000  0.001624 2011       1


Crosswalk census tract to zipcode
hud_cw_tract_zip(tract = 48201223100, year = c('2017'), quarter = c('1'))
#> 
#>         tract   zip res_ratio bus_ratio oth_ratio tot_ratio year quarter
#> 1 48201223100 77032         1   0.95425         1  0.991617 2017       1
#> 2 48201223100 77396         0   0.04575         0  0.008383 2017       1


Crosswalk county fip into zipcode
hud_cw_county_zip(county = '22031', year = c('2010'), quarter = c('1'))
#> 
#>    county   zip res_ratio bus_ratio oth_ratio tot_ratio year quarter
#> 1   22031 71052 0.4322130  0.699634   0.56338 0.4455100 2010       1
#> 2   22031 71078 0.1816700  0.086081   0.15493 0.1770400 2010       1
#> 3   22031 71049 0.1103580  0.065934   0.15493 0.1085520 2010       1
#> 4   22031 71032 0.0813449  0.040293   0.01408 0.0790172 2010       1
#> 5   22031 71027 0.0699566  0.047619   0.04225 0.0687441 2010       1
#> 6   22031 71030 0.0435647  0.020147   0.04225 0.0424621 2010       1
#> 7   22031 71046 0.0425705  0.021978   0.01408 0.0414348 2010       1
#> 8   22031 71063 0.0275669  0.014652   0.01408 0.0268813 2010       1
#> 9   22031 71419 0.0105748  0.003663   0.00000 0.0101875 2010       1
#> 10  22031 71065 0.0001808  0.000000   0.00000 0.0001712 2010       1


Crosswalk core based statistical areas (cbsa) to zipcode
hud_cw_cbsa_zip(cbsa = '10140', year = c('2017'), quarter = c('2'))
#> 
#>     cbsa   zip res_ratio bus_ratio oth_ratio tot_ratio year quarter
#> 1  10140 98520 3.384e-01 0.5520178 0.4216084 3.573e-01 2017       2
#> 2  10140 98550 1.823e-01 0.1780822 0.2258327 1.835e-01 2017       2
#> 3  10140 98569 1.268e-01 0.0744169 0.1283509 1.230e-01 2017       2
#> 4  10140 98563 1.166e-01 0.0995927 0.1064175 1.150e-01 2017       2
#> 5  10140 98541 1.001e-01 0.0377638 0.0609261 9.411e-02 2017       2
#> 6  10140 98557 4.417e-02 0.0148093 0.0138099 4.093e-02 2017       2
#> 7  10140 98537 3.694e-02 0.0159200 0.0138099 3.457e-02 2017       2
#> 8  10140 98568 2.151e-02 0.0011107 0.0040617 1.938e-02 2017       2
#> 9  10140 98595 1.415e-02 0.0103665 0.0154346 1.391e-02 2017       2
#> 10 10140 98547 5.923e-03 0.0029619 0.0024370 5.581e-03 2017       2
#> 11 10140 98535 2.993e-03 0.0011107 0.0016247 2.805e-03 2017       2
#> 12 10140 98575 2.899e-03 0.0014809 0.0008123 2.721e-03 2017       2
#> 13 10140 98526 2.307e-03 0.0051833 0.0000000 2.444e-03 2017       2
#> 14 10140 98552 1.964e-03 0.0025916 0.0000000 1.944e-03 2017       2
#> 15 10140 98536 1.964e-03 0.0007405 0.0000000 1.805e-03 2017       2
#> 16 10140 98571 6.546e-04 0.0007405 0.0016247 6.942e-04 2017       2
#> 17 10140 98579 2.494e-04 0.0000000 0.0000000 2.221e-04 2017       2
#> 18 10140 98559 3.117e-05 0.0007405 0.0000000 8.331e-05 2017       2
#> 19 10140 98562 0.000e+00 0.0003702 0.0008123 5.554e-05 2017       2
#> 20 10140 98583 0.000e+00 0.0000000 0.0008123 2.777e-05 2017       2
#> 21 10140 98587 0.000e+00 0.0000000 0.0008123 2.777e-05 2017       2
#> 22 10140 98566 0.000e+00 0.0000000 0.0008123 2.777e-05 2017       2


Crosswalk core based statistical areas division (cbsadiv) to zipcode
hud_cw_cbsadiv_zip(cbsadiv = 10380, year = c('2017'), quarter = c('4'))
#> 
#>    cbsa_div   zip res_ratio bus_ratio oth_ratio tot_ratio year quarter
#> 1     10380 00662 0.1640649  0.185800  0.147385 1.652e-01 2017       4
#> 2     10380 00603 0.1564245  0.142274  0.407290 1.582e-01 2017       4
#> 3     10380 00685 0.1352663  0.138602  0.076070 1.349e-01 2017       4
#> 4     10380 00602 0.1003411  0.102149  0.061807 1.000e-01 2017       4
#> 5     10380 00610 0.0840450  0.075490  0.037242 8.304e-02 2017       4
#> 6     10380 00641 0.0810440  0.090996  0.081616 8.166e-02 2017       4
#> 7     10380 00676 0.0817030  0.066785  0.045959 8.042e-02 2017       4
#> 8     10380 00669 0.0679181  0.054815  0.025357 6.668e-02 2017       4
#> 9     10380 00677 0.0574370  0.055359  0.102219 5.778e-02 2017       4
#> 10    10380 00605 0.0337231  0.048014  0.001585 3.426e-02 2017       4
#> 11    10380 00690 0.0264032  0.018906  0.007132 2.575e-02 2017       4
#> 12    10380 00604 0.0057615  0.017546  0.001585 6.434e-03 2017       4
#> 13    10380 00611 0.0056725  0.003128  0.001585 5.475e-03 2017       4
#> 14    10380 00612 0.0001959  0.000136  0.001585 2.068e-04 2017       4
#> 15    10380 00631 0.0000000  0.000000  0.001585 1.654e-05 2017       4


Crosswalk congressional district (cd) to zipcode
hud_cw_cd_zip(cd = '2202', year = c('2010'), quarter = c('4'))
#> 
#>      cd   zip res_ratio bus_ratio oth_ratio tot_ratio year quarter
#> 1  2202 70072 0.0873171 6.011e-02 0.0383332 8.356e-02 2010       4
#> 2  2202 70115 0.0700244 6.151e-02 0.0831270 6.984e-02 2010       4
#> 3  2202 70119 0.0689893 7.905e-02 0.0521159 6.916e-02 2010       4
#> 4  2202 70058 0.0621786 5.956e-02 0.1148918 6.382e-02 2010       4
#> 5  2202 70094 0.0559088 2.953e-02 0.0506084 5.374e-02 2010       4
#> 6  2202 70117 0.0563989 3.658e-02 0.0189512 5.360e-02 2010       4
#> 7  2202 70122 0.0560060 2.443e-02 0.0243351 5.252e-02 2010       4
#> 8  2202 70130 0.0438001 1.326e-01 0.1001400 5.245e-02 2010       4
#> 9  2202 70114 0.0511557 3.982e-02 0.0505007 5.028e-02 2010       4
#> 10 2202 70118 0.0520726 2.443e-02 0.0325186 4.931e-02 2010       4
#> 11 2202 70131 0.0484644 1.244e-02 0.0328416 4.521e-02 2010       4
#> 12 2202 70126 0.0421946 2.998e-02 0.0360719 4.106e-02 2010       4
#> 13 2202 70127 0.0378133 2.358e-02 0.0369333 3.671e-02 2010       4
#> 14 2202 70056 0.0353248 2.828e-02 0.0390869 3.493e-02 2010       4
#> 15 2202 70116 0.0319406 4.517e-02 0.0675137 3.418e-02 2010       4
#> 16 2202 70065 0.0333898 1.114e-02 0.0648218 3.281e-02 2010       4
#> 17 2202 70062 0.0249526 8.814e-02 0.0412404 3.028e-02 2010       4
#> 18 2202 70125 0.0298282 2.718e-02 0.0187359 2.924e-02 2010       4
#> 19 2202 70128 0.0290761 5.197e-03 0.0043071 2.641e-02 2010       4
#> 20 2202 70113 0.0189405 3.168e-02 0.0330570 2.039e-02 2010       4
#> 21 2202 70053 0.0186194 4.232e-02 0.0179821 2.038e-02 2010       4
#> 22 2202 70112 0.0134058 5.072e-02 0.0194896 1.643e-02 2010       4
#> 23 2202 70129 0.0139466 1.404e-02 0.0059223 1.367e-02 2010       4
#> 24 2202 70003 0.0064473 1.054e-02 0.0052762 6.715e-03 2010       4
#> 25 2202 70121 0.0040264 6.396e-03 0.0055992 4.260e-03 2010       4
#> 26 2202 70124 0.0045376 1.049e-03 0.0015075 4.169e-03 2010       4
#> 27 2202 70123 0.0016308 7.995e-04 0.0023689 1.594e-03 2010       4
#> 28 2202 70001 0.0004352 8.944e-03 0.0007537 1.087e-03 2010       4
#> 29 2202 70067 0.0011745 3.498e-04 0.0000000 1.071e-03 2010       4
#> 30 2202 70170 0.0000000 5.496e-03 0.0003230 4.248e-04 2010       4
#> 31 2202 70163 0.0000000 4.597e-03 0.0002154 3.534e-04 2010       4
#> 32 2202 70139 0.0000000 3.698e-03 0.0002154 2.857e-04 2010       4
#> 33 2202 70146 0.0000000 4.997e-04 0.0002154 4.511e-05 2010       4
#> 34 2202 70143 0.0000000 4.997e-05 0.0000000 3.760e-06 2010       4
#> 35 2202 70165 0.0000000 4.997e-05 0.0000000 3.760e-06 2010       4
#> 36 2202 70141 0.0000000 4.997e-05 0.0000000 3.760e-06 2010       4


Crosswalk zipcode to county subdivision (countysub)
hud_cw_zip_countysub(zip = '35213', year = c('2019'), quarter = c('2'))
#> 
#>     zip        zip res_ratio bus_ratio oth_ratio tot_ratio year quarter
#> 1 35213 0107390324         1         1         1         1 2019       2


Crosswalk county subdivision (countysub) to zipcode
hud_cw_countysub_zip(countysub = '4606720300 ', year = c('2019', '2019', '2019'),
                     quarter = c('4','4'))
#> 
#>   county_sub   zip res_ratio bus_ratio oth_ratio tot_ratio year quarter
#> 1 4606720300 57376         1         1         0         1 2019       4


Querying for only the crosswalked geoids

If you just want the crosswalked geoids, you can set the minimal argument to TRUE. This will return a vector containing the crosswalked geoids without the extra metadata.

hud_cw_county_zip(county = '22031', year = c('2010'), quarter = c('1'), minimal = TRUE)
#> 
#>  [1] "71052" "71078" "71049" "71032" "71027" "71030" "71046" "71063" "71419"
#> [10] "71065"


Using the omni function for querying

The omni function is a redundant implementation of the functions shown above that requires specifying the type which can be from 1-12. The type argument follows the number scheme described at within the [input arguments][Input Arguments]. You also must use the ‘query’ argument (i.e query = 22031) for inputting geoids instead of the specific geoid names (i.e county = 22031, cd = 7200) used by the above functions.

hud_cw(type = 7, query = '22031', year = c('2010'), quarter = c('1'))
#> 
#>    county geoid res_ratio bus_ratio oth_ratio tot_ratio year quarter
#> 1   22031 71052 0.4322130  0.699634   0.56338 0.4455100 2010       1
#> 2   22031 71078 0.1816700  0.086081   0.15493 0.1770400 2010       1
#> 3   22031 71049 0.1103580  0.065934   0.15493 0.1085520 2010       1
#> 4   22031 71032 0.0813449  0.040293   0.01408 0.0790172 2010       1
#> 5   22031 71027 0.0699566  0.047619   0.04225 0.0687441 2010       1
#> 6   22031 71030 0.0435647  0.020147   0.04225 0.0424621 2010       1
#> 7   22031 71046 0.0425705  0.021978   0.01408 0.0414348 2010       1
#> 8   22031 71063 0.0275669  0.014652   0.01408 0.0268813 2010       1
#> 9   22031 71419 0.0105748  0.003663   0.00000 0.0101875 2010       1
#> 10  22031 71065 0.0001808  0.000000   0.00000 0.0001712 2010       1


Crosswalking a dataset

For those who need to apply an allocation method (residential, business, other, total) to individual items in a data set, the crosswalk() function is available. Lets say we wanted to know the population at a zip code level (there is likely already a data set for this) for the counties of Washington, Wicomico, and Worchester in Maryland in the year 2019.

NOTE: The use of the crosswalk() function is likely best suited for datasets that are not described in the geographic identifier we want to crosswalk to. In this case population might not be the best example for this.

sample <- data.frame(pop = c(151049, 103609, 52276),
                     county = c("24043", "24045", "24047"))

head(sample)
#>      pop county
#> 1 151049  24043
#> 2 103609  24045
#> 3  52276  24047

In the crosswalked data set below each zip code associated with a county is assigned the same population value.

crosswalk(data = sample, geoid = "county", geoid_col = "county", 
          cw_geoid = "zip", cw_geoid_col = NA, method = NA, year = 2019
          , quarter = 1)
#> 
#> 
#> * No method or cw_geoid_col specified: will just merge the datasets.
#>    county   zip res_ratio bus_ratio oth_ratio tot_ratio year quarter    pop
#> 1   24043 21740 4.154e-01 0.5855329 0.6520012 4.388e-01 2019       1 151049
#> 2   24043 21742 2.269e-01 0.2051453 0.2022609 2.242e-01 2019       1 151049
#> 3   24043 21795 7.331e-02 0.0689943 0.0498014 7.197e-02 2019       1 151049
#> 4   24043 21713 5.965e-02 0.0295690 0.0192484 5.558e-02 2019       1 151049
#> 5   24043 21783 4.411e-02 0.0126963 0.0033608 3.993e-02 2019       1 151049
#> 6   24043 21722 3.437e-02 0.0075175 0.0030553 3.094e-02 2019       1 151049
#> 7   24043 21750 2.974e-02 0.0414300 0.0262756 3.051e-02 2019       1 151049
#> 8   24043 21782 2.497e-02 0.0046776 0.0009166 2.237e-02 2019       1 151049
#> 9   24043 21756 2.179e-02 0.0018376 0.0009166 1.934e-02 2019       1 151049
#> 10  24043 21767 1.567e-02 0.0145339 0.0137489 1.550e-02 2019       1 151049
#> 11  24043 21719 1.093e-02 0.0030070 0.0265811 1.098e-02 2019       1 151049
#> 12  24043 21734 1.081e-02 0.0150351 0.0012221 1.073e-02 2019       1 151049
#> 13  24043 21758 1.118e-02 0.0030070 0.0006111 1.010e-02 2019       1 151049
#> 14  24043 21733 6.992e-03 0.0021717 0.0000000 6.318e-03 2019       1 151049
#> 15  24043 21711 6.903e-03 0.0015035 0.0000000 6.187e-03 2019       1 151049
#> 16  24043 21779 5.866e-03 0.0016706 0.0000000 5.289e-03 2019       1 151049
#> 17  24043 21715 5.481e-04 0.0001671 0.0000000 4.950e-04 2019       1 151049
#> 18  24043 21780 4.740e-04 0.0000000 0.0000000 4.168e-04 2019       1 151049
#> 19  24043 21769 2.370e-04 0.0003341 0.0000000 2.345e-04 2019       1 151049
#> 20  24043 21720 2.963e-05 0.0001671 0.0000000 3.908e-05 2019       1 151049
#> 21  24043 21746 0.000e+00 0.0005012 0.0000000 3.908e-05 2019       1 151049
#> 22  24043 21755 1.481e-05 0.0000000 0.0000000 1.303e-05 2019       1 151049
#> 23  24043 21781 0.000e+00 0.0001671 0.0000000 1.303e-05 2019       1 151049
#> 24  24043 21721 0.000e+00 0.0001671 0.0000000 1.303e-05 2019       1 151049
#> 25  24043 21741 0.000e+00 0.0001671 0.0000000 1.303e-05 2019       1 151049
#> 26  24045 21804 3.617e-01 0.2666006 0.4497751 3.574e-01 2019       1 103609
#> 27  24045 21801 2.563e-01 0.4428147 0.4677661 2.830e-01 2019       1 103609
#> 28  24045 21826 6.512e-02 0.0471754 0.0228636 6.152e-02 2019       1 103609
#> 29  24045 21875 6.282e-02 0.0243806 0.0356072 5.809e-02 2019       1 103609
#> 30  24045 21802 4.247e-02 0.1117939 0.0007496 4.670e-02 2019       1 103609
#> 31  24045 21830 3.543e-02 0.0059465 0.0018741 3.121e-02 2019       1 103609
#> 32  24045 21849 3.141e-02 0.0053518 0.0052474 2.784e-02 2019       1 103609
#> 33  24045 21850 2.981e-02 0.0114965 0.0089955 2.719e-02 2019       1 103609
#> 34  24045 21837 2.548e-02 0.0105055 0.0026237 2.306e-02 2019       1 103609
#> 35  24045 21874 2.180e-02 0.0073340 0.0022489 1.958e-02 2019       1 103609
#> 36  24045 21803 1.634e-02 0.0537166 0.0003748 1.893e-02 2019       1 103609
#> 37  24045 21822 1.714e-02 0.0043608 0.0007496 1.522e-02 2019       1 103609
#> 38  24045 21856 9.956e-03 0.0033697 0.0000000 8.897e-03 2019       1 103609
#> 39  24045 21861 8.827e-03 0.0001982 0.0011244 7.692e-03 2019       1 103609
#> 40  24045 21865 5.789e-03 0.0025768 0.0000000 5.228e-03 2019       1 103609
#> 41  24045 21840 5.112e-03 0.0011893 0.0000000 4.519e-03 2019       1 103609
#> 42  24045 21814 4.434e-03 0.0005946 0.0000000 3.881e-03 2019       1 103609
#> 43  24045 21852 0.000e+00 0.0003964 0.0000000 3.545e-05 2019       1 103609
#> 44  24045 21810 0.000e+00 0.0001982 0.0000000 1.772e-05 2019       1 103609
#> 45  24047 21842 5.302e-01 0.4559211 0.8379953 5.443e-01 2019       1  52276
#> 46  24047 21811 2.832e-01 0.2535088 0.0927739 2.696e-01 2019       1  52276
#> 47  24047 21851 5.434e-02 0.0881579 0.0417249 5.577e-02 2019       1  52276
#> 48  24047 21843 4.340e-02 0.1065789 0.0009324 4.491e-02 2019       1  52276
#> 49  24047 21863 3.859e-02 0.0660088 0.0205128 3.927e-02 2019       1  52276
#> 50  24047 21813 2.390e-02 0.0160088 0.0048951 2.221e-02 2019       1  52276
#> 51  24047 21841 7.577e-03 0.0041667 0.0004662 6.918e-03 2019       1  52276
#> 52  24047 21872 6.003e-03 0.0039474 0.0004662 5.528e-03 2019       1  52276
#> 53  24047 21864 4.920e-03 0.0017544 0.0000000 4.411e-03 2019       1  52276
#> 54  24047 21829 3.411e-03 0.0008772 0.0000000 3.036e-03 2019       1  52276
#> 55  24047 21804 1.804e-03 0.0004386 0.0000000 1.604e-03 2019       1  52276
#> 56  24047 21862 1.263e-03 0.0024123 0.0002331 1.275e-03 2019       1  52276
#> 57  24047 21822 1.361e-03 0.0000000 0.0000000 1.189e-03 2019       1  52276
#> 58  24047 21792 0.000e+00 0.0002193 0.0000000 1.432e-05 2019       1  52276


To utilize an allocation method provided by the crosswalk files and apply it to columns of the data set, specify the method and cw_geoid_col arguments. In this case we want to allocate the county population levels to a zip code level using the method based on the ratio of residential addresses.


crosswalk(data = sample, geoid = "county", geoid_col = "county", 
          cw_geoid = "zip", cw_geoid_col = "pop", method = "res", year = 2019
          , quarter = 1)
#> 
#> 
#> * Applying allocation method based on residential address percentage.
#>    county   zip res_ratio bus_ratio oth_ratio tot_ratio year quarter       pop
#> 1   24043 21740 4.154e-01 0.5855329 0.6520012 4.388e-01 2019       1 62751.933
#> 2   24043 21742 2.269e-01 0.2051453 0.2022609 2.242e-01 2019       1 34280.196
#> 3   24043 21795 7.331e-02 0.0689943 0.0498014 7.197e-02 2019       1 11073.212
#> 4   24043 21713 5.965e-02 0.0295690 0.0192484 5.558e-02 2019       1  9010.270
#> 5   24043 21783 4.411e-02 0.0126963 0.0033608 3.993e-02 2019       1  6663.170
#> 6   24043 21722 3.437e-02 0.0075175 0.0030553 3.094e-02 2019       1  5190.918
#> 7   24043 21750 2.974e-02 0.0414300 0.0262756 3.051e-02 2019       1  4492.829
#> 8   24043 21782 2.497e-02 0.0046776 0.0009166 2.237e-02 2019       1  3772.365
#> 9   24043 21756 2.179e-02 0.0018376 0.0009166 1.934e-02 2019       1  3291.310
#> 10  24043 21767 1.567e-02 0.0145339 0.0137489 1.550e-02 2019       1  2367.238
#> 11  24043 21719 1.093e-02 0.0030070 0.0265811 1.098e-02 2019       1  1651.249
#> 12  24043 21734 1.081e-02 0.0150351 0.0012221 1.073e-02 2019       1  1633.349
#> 13  24043 21758 1.118e-02 0.0030070 0.0006111 1.010e-02 2019       1  1689.286
#> 14  24043 21733 6.992e-03 0.0021717 0.0000000 6.318e-03 2019       1  1056.083
#> 15  24043 21711 6.903e-03 0.0015035 0.0000000 6.187e-03 2019       1  1042.659
#> 16  24043 21779 5.866e-03 0.0016706 0.0000000 5.289e-03 2019       1   886.036
#> 17  24043 21715 5.481e-04 0.0001671 0.0000000 4.950e-04 2019       1    82.786
#> 18  24043 21780 4.740e-04 0.0000000 0.0000000 4.168e-04 2019       1    71.599
#> 19  24043 21769 2.370e-04 0.0003341 0.0000000 2.345e-04 2019       1    35.799
#> 20  24043 21720 2.963e-05 0.0001671 0.0000000 3.908e-05 2019       1     4.475
#> 21  24043 21746 0.000e+00 0.0005012 0.0000000 3.908e-05 2019       1     0.000
#> 22  24043 21755 1.481e-05 0.0000000 0.0000000 1.303e-05 2019       1     2.237
#> 23  24043 21781 0.000e+00 0.0001671 0.0000000 1.303e-05 2019       1     0.000
#> 24  24043 21721 0.000e+00 0.0001671 0.0000000 1.303e-05 2019       1     0.000
#> 25  24043 21741 0.000e+00 0.0001671 0.0000000 1.303e-05 2019       1     0.000
#> 26  24045 21804 3.617e-01 0.2666006 0.4497751 3.574e-01 2019       1 37479.352
#> 27  24045 21801 2.563e-01 0.4428147 0.4677661 2.830e-01 2019       1 26557.357
#> 28  24045 21826 6.512e-02 0.0471754 0.0228636 6.152e-02 2019       1  6746.751
#> 29  24045 21875 6.282e-02 0.0243806 0.0356072 5.809e-02 2019       1  6508.531
#> 30  24045 21802 4.247e-02 0.1117939 0.0007496 4.670e-02 2019       1  4400.703
#> 31  24045 21830 3.543e-02 0.0059465 0.0018741 3.121e-02 2019       1  3671.152
#> 32  24045 21849 3.141e-02 0.0053518 0.0052474 2.784e-02 2019       1  3254.265
#> 33  24045 21850 2.981e-02 0.0114965 0.0089955 2.719e-02 2019       1  3088.362
#> 34  24045 21837 2.548e-02 0.0105055 0.0026237 2.306e-02 2019       1  2639.571
#> 35  24045 21874 2.180e-02 0.0073340 0.0022489 1.958e-02 2019       1  2258.843
#> 36  24045 21803 1.634e-02 0.0537166 0.0003748 1.893e-02 2019       1  1693.069
#> 37  24045 21822 1.714e-02 0.0043608 0.0007496 1.522e-02 2019       1  1776.021
#> 38  24045 21856 9.956e-03 0.0033697 0.0000000 8.897e-03 2019       1  1031.581
#> 39  24045 21861 8.827e-03 0.0001982 0.0011244 7.692e-03 2019       1   914.597
#> 40  24045 21865 5.789e-03 0.0025768 0.0000000 5.228e-03 2019       1   599.806
#> 41  24045 21840 5.112e-03 0.0011893 0.0000000 4.519e-03 2019       1   529.616
#> 42  24045 21814 4.434e-03 0.0005946 0.0000000 3.881e-03 2019       1   459.426
#> 43  24045 21852 0.000e+00 0.0003964 0.0000000 3.545e-05 2019       1     0.000
#> 44  24045 21810 0.000e+00 0.0001982 0.0000000 1.772e-05 2019       1     0.000
#> 45  24047 21842 5.302e-01 0.4559211 0.8379953 5.443e-01 2019       1 27719.003
#> 46  24047 21811 2.832e-01 0.2535088 0.0927739 2.696e-01 2019       1 14804.331
#> 47  24047 21851 5.434e-02 0.0881579 0.0417249 5.577e-02 2019       1  2840.491
#> 48  24047 21843 4.340e-02 0.1065789 0.0009324 4.491e-02 2019       1  2268.620
#> 49  24047 21863 3.859e-02 0.0660088 0.0205128 3.927e-02 2019       1  2017.408
#> 50  24047 21813 2.390e-02 0.0160088 0.0048951 2.221e-02 2019       1  1249.199
#> 51  24047 21841 7.577e-03 0.0041667 0.0004662 6.918e-03 2019       1   396.108
#> 52  24047 21872 6.003e-03 0.0039474 0.0004662 5.528e-03 2019       1   313.800
#> 53  24047 21864 4.920e-03 0.0017544 0.0000000 4.411e-03 2019       1   257.213
#> 54  24047 21829 3.411e-03 0.0008772 0.0000000 3.036e-03 2019       1   178.334
#> 55  24047 21804 1.804e-03 0.0004386 0.0000000 1.604e-03 2019       1    94.311
#> 56  24047 21862 1.263e-03 0.0024123 0.0002331 1.275e-03 2019       1    66.018
#> 57  24047 21822 1.361e-03 0.0000000 0.0000000 1.189e-03 2019       1    71.162
#> 58  24047 21792 0.000e+00 0.0002193 0.0000000 1.432e-05 2019       1     0.000


Geo-in-geo functions: does one geography overlap another?

This library also allows the user to determine if one geography overlaps another.

Disclaimer: Overlap is not determined by whether the boundaries intersect, but rather if any addresses lie in both.

The function below queries for if zipcode 71052 overlaps cbsa 43340.

# 71052 %z_in_cbsa% 43340

The infix operator used above defaults to the most recent crosswalk files available. Furthermore, you must have the HUD_KEY system environment variable set before using them: check the Setup page.

The non infix version is also available: this allows you to specify the year, quarter, and key arguments.

# z_in_cbsa(zip = 71052, cbsa = 43340, year = 2019, quarter = 2)

Most recent USPS Crosswalk files

To get the most recent crosswalk files by year and quarter:

# hud_rec_cw_yr()

Parameters

Parameter Description
query

The query argument name is the first geoid in the function call. For example, zip-county would have the ‘zip’ argument name as the query.

Functions #1-5 and #11 must specify a 5 digit zip code in the zip function argument.

* zip = 22031


Function #6 must specify an 11 digit number consisting of state FIPS + county FIPS + tract code tract in the tract function argument.

* tract = 51059461700


Function #7 must specify a 5 digit county fips code in the county function argument.

* county = 51600


Function #8 must specify a micropolitan or metropolitan CBSA code in the cbsa function argument.

* cbsa = 10380


Function #9 must specify a metropolitan CBSA division code in the cbsadiv function argument.

* cbsadiv = 35614


I recommend typing hud_metropolitan(“MD”) to see a list of metropolitan CBSA in Maryland. For example, a code of METRO22900N40079 needs 22900 inside as the input argument.

Function #10 must be a 2 digit state fips code + 2 digit congressional district code in the cd function argument.

* cd = 7200


Function #12 must be a 10 digit number consisting of 5 digit county fips code + 5 digit county sub district code in the countysub argument.

* countysub = 4606720300


year Years of the data to retrieve: defaults to the current year.

* year = c(2019, 2018, 2021) * year = c(2016) * year = 2021
quarter The quarters in the year to retrieve: defaults to the first quarter.

* quarter = c(1,2,3,4) * quarter = c(1) * quarter = 4
minimal If TRUE, returns just the intersecting geoids that are crosswalked with the queried geoid.
key The API key provided by HUD USER.

* key = “wqokqo2138jdi13wfwwfwcytjyr”

Returns

Return Field Description
zip,
county,
fips,
tract,
cbsa,
cbsadiv,
cd,
countysub
The geoid that is queried for. The name of the column will be named the geoid type
res_ratio The ratio of residential addresses in the ZIP – Tract, County, or CBSA part to the total number of residential addresses in the entire ZIP. (for type 1-5 and 11) The ratio of residential addresses in the Zip, Tract, County, or CBSA - ZIP part to the total number of residential addresses in the entire Zip, Tract, County, or CBSA. (for type 6-10 and 12)
bus_ratio The ratio of business addresses in the ZIP – Tract, County, or CBSA part to the total number of business addresses in the entire ZIP. (for type 1-5 and 11). The ratio of business addresses in the Tract, County, or CBSA – ZIP part to the total number of business addresses in the entire Tract, County, or CBSA. (for type 6-10 and 12)
oth_ratio The ratio of other addresses in the ZIP – Tract to the total number of other addresses in the entire ZIP. (for type 1-5 and 11). The ratio of other addresses in the Tract, County, or CBSA – ZIP part to the total number of other addresses in the entire Tract, County, or CBSA. (for type 6-10 and 12)
tot_ratio The ratio of all addresses in the ZIP – Tract to the total number of all types of addresses in the entire ZIP. (for type 1-5 and 11) The ratio of all addresses in the Tract, County, or CBSA-ZIP part to the total number of all types of addresses in the entire Tract, County, or CBSA. (for type 6-10 and 12)
zip,
county,
fips,
tract,
cbsa,
cbsadiv,
cd,
countysub
The intersecting geoids depending on function call
year Year the measurement was taken.
quarter Quarter of year when measurement was taken.

References

Din, Alexander and Wilson, Ron, 2020. “Crosswalking ZIP Codes to Census
      Geographies: Geoprocessing the U.S. Department of Housing & Urban Development’s
      ZIP Code Crosswalk Files,” Cityscape: A Journal of Policy Development and
      Research, Volume 22, Number 1, https://www.huduser.gov/portal/periodicals/cityscpe/vol22num1/ch12.pdf

Katy Rossiter, K. R. (2014, July 31). Standard Hierarchy of Census Bereau
      Geographies [Photograph]. Understanding Geographic Relationships: Counties,
      Places, Tracts and More.
      https://www.census.gov/newsroom/blogs/random-samplings/2014/07/understanding-geographic-relation
      ships-counties-places-tracts-and-more.html

U.S Department of Housing and Urban Development. (n.d.). HUD USPS ZIP
      Code Crosswalk Files | HUD USER. HUD USPS ZIP CODE CROSSWALK FILES.
      Retrieved February 17, 2022, from
      https://www.huduser.gov/portal/datasets/usps_crosswalk.html

Wilson, Ron and Din, Alexander, 2018. “Understanding and Enhancing the U.S.
      Department of Housing and Urban Development’s ZIP Code Crosswalk Files,”
      Cityscape: A Journal of Policy Development and Research, Volume 20 Number 2, 277
      – 294.