The sedtR
package allows R programmers to easily interact with Urban’s
Spatial Equity Data
Tool (SEDT) public
application programming
interface
(API).
The SEDT enables local, state, and federal leaders, as well as the general public, to upload their own point spatial data and quickly assess whether place-based programs and resources – such as parks, libraries, wi-fi hotspots or electric vehicle charging stations – are equitably distributed across neighborhoods and demographic groups.
The tool – launched in 2020 and expanded in 2021 – has been used by a wide variety of experts and nonexperts alike to assess equity in the distribution of local programs and resources. For example, the Bloomington Pedestrian and Bicycle Safety Commission analyzed sidewalk funding allocations, and advocates in Cincinnati identified economic and racial inequities in car crash locations.
Through engagements with local government and nonprofit users, we
identified a key barrier. Organizations wanted to embed the SEDT within
their own tools and data workflows and thus make the Tool a core part of
institutional processes. However, before the API’s release in March of
2024, Tool users would have had to visit Urban’s website and use the GUI
interface to upload one dataset at a time whenever new analyses were
needed. The release of the API overcomes this barrier by allowing
programmatic access to the Tool. We wrote sedtR
to wrap the public
API’s endpoints in user-friendly R code. We are hopeful that sedtR
makes it easy for researchers, analysts, and policymakers to incorporate
SEDT calculations into R workflows.
The SEDT enables local, state, and federal leaders, as well as the general public, to upload their own point spatial data and quickly assess whether place-based programs and resources – such as parks, libraries, wi-fi hotspots or electric vehicle charging stations – are equitably distributed across neighborhoods and demographic groups.
You can install the development version of sedtR from GitHub with:
# install.packages("devtools")
devtools::install_github("UrbanInstitute/sedtR")
The following example illustrates using the call_sedt_api()
function
on Minneapolis, MN bikeshare data stored on the Urban Institute’s Data
Catalog.
#> [1] "getting output file"
create_map(sedt_response$geo_bias_data, save_map = FALSE)
A data frame with demographic information used in the analysis is also returned:
sedt_response$demo_bias_data
#> census_var data_value summary_value diff_data_city
#> 1 pct_no_internet 8.78435 7.752 1.03235
#> 2 pct_under_200_poverty_line 37.70731 33.240 4.46731
#> 3 pct_all_other_races 6.23852 6.280 -0.04148
#> 4 pct_less_hs_diploma 10.10677 9.295 0.81177
#> 5 pct_under18_unins 4.50332 3.074 1.42932
#> 6 pct_under18_pov 19.22721 21.193 -1.96579
#> 7 pct_under18_disability 4.31995 4.882 -0.56205
#> 8 pct_under18_white_alone 36.54806 41.492 -4.94394
#> 9 pct_under18_black_alone 32.97229 30.788 2.18429
#> 10 pct_under18_asian_alone 6.53558 4.951 1.58458
#> 11 pct_under18_hisp 13.67276 17.267 -3.59424
#> 12 pct_under18_all_other_races_alone 22.93145 22.769 0.16245
#> 13 pct_under18_limited_eng_hh 8.01230 9.349 -1.33670
#> 14 pct_pov_children 15.36556 24.606 -9.24044
#> 15 pct_pov_seniors 12.93859 8.065 4.87359
#> 16 pct_pov_white_alone 49.88414 39.334 10.55014
#> 17 pct_pov_black_alone 30.82189 38.261 -7.43911
#> 18 pct_pov_asian_alone 7.10258 6.253 0.84958
#> 19 pct_pov_hisp 6.61893 10.454 -3.83507
#> 20 pct_pov_bach 29.48083 19.405 10.07583
#> 21 pct_pov_less_than_hs 17.84389 27.908 -10.06411
#> 22 pct_pov_unemployed 20.22115 19.745 0.47615
#> 23 pct_pov_veterans 4.23025 2.861 1.36925
#> 24 pct_pov_disability 23.07845 21.359 1.71945
#> 25 pct_pov_unins 9.40374 8.424 0.97974
#> 26 pct_pov_all_other_races_alone 12.19148 16.152 -3.96052
#> 27 pct_black 19.37671 18.213 1.16371
#> 28 pct_white 58.73595 60.073 -1.33705
#> 29 pct_asian 6.97013 5.601 1.36913
#> 30 pct_hisp 8.68658 9.832 -1.14542
#> 31 pct_children 15.33392 19.734 -4.40008
#> 32 pct_seniors 10.30962 10.183 0.12662
#> 33 pct_veterans 3.59873 3.654 -0.05527
#> 34 pct_unins 6.47823 6.147 0.33123
#> 35 pct_disability 11.71519 11.006 0.70919
#> 36 pct_renters 64.97899 51.936 13.04299
#> 37 pct_limited_eng_hh 5.57089 4.925 0.64589
#> 38 pct_bach 31.92228 31.746 0.17628
#> 39 pct_under_poverty_line 21.61443 17.027 4.58743
#> 40 pct_cb_renter_hh 35.34203 35.942 -0.59997
#> 41 pct_unemp 5.98937 5.624 0.36537
#> data_value_sd summary_value_margin sig_diff geo geo_fips geo_display
#> 1 0.54109 0.508 FALSE city 2743000 Minneapolis, MN
#> 2 0.74891 0.955 TRUE city 2743000 Minneapolis, MN
#> 3 0.32612 0.395 FALSE city 2743000 Minneapolis, MN
#> 4 0.62023 0.532 FALSE city 2743000 Minneapolis, MN
#> 5 1.49243 0.495 FALSE city 2743000 Minneapolis, MN
#> 6 2.10830 1.697 FALSE city 2743000 Minneapolis, MN
#> 7 0.77004 0.692 FALSE city 2743000 Minneapolis, MN
#> 8 2.20083 0.935 TRUE city 2743000 Minneapolis, MN
#> 9 2.20357 1.471 FALSE city 2743000 Minneapolis, MN
#> 10 1.27801 0.532 FALSE city 2743000 Minneapolis, MN
#> 11 1.43581 1.182 FALSE city 2743000 Minneapolis, MN
#> 12 1.89577 1.237 FALSE city 2743000 Minneapolis, MN
#> 13 1.82605 1.690 FALSE city 2743000 Minneapolis, MN
#> 14 1.15044 2.598 TRUE city 2743000 Minneapolis, MN
#> 15 1.30532 0.746 TRUE city 2743000 Minneapolis, MN
#> 16 2.80928 0.930 TRUE city 2743000 Minneapolis, MN
#> 17 1.74627 3.219 TRUE city 2743000 Minneapolis, MN
#> 18 1.00077 0.908 FALSE city 2743000 Minneapolis, MN
#> 19 0.83831 1.600 TRUE city 2743000 Minneapolis, MN
#> 20 2.15559 1.401 TRUE city 2743000 Minneapolis, MN
#> 21 1.37517 2.378 TRUE city 2743000 Minneapolis, MN
#> 22 2.00394 2.362 FALSE city 2743000 Minneapolis, MN
#> 23 1.10728 0.705 FALSE city 2743000 Minneapolis, MN
#> 24 1.32205 1.071 FALSE city 2743000 Minneapolis, MN
#> 25 0.97177 0.973 FALSE city 2743000 Minneapolis, MN
#> 26 1.01236 1.860 FALSE city 2743000 Minneapolis, MN
#> 27 0.59730 0.823 FALSE city 2743000 Minneapolis, MN
#> 28 0.66
8000
423 0.535 FALSE city 2743000 Minneapolis, MN
#> 29 0.36618 0.400 TRUE city 2743000 Minneapolis, MN
#> 30 0.43904 0.637 FALSE city 2743000 Minneapolis, MN
#> 31 0.40066 0.590 TRUE city 2743000 Minneapolis, MN
#> 32 0.36199 0.280 FALSE city 2743000 Minneapolis, MN
#> 33 0.24141 0.241 FALSE city 2743000 Minneapolis, MN
#> 34 0.29662 0.375 FALSE city 2743000 Minneapolis, MN
#> 35 0.39128 0.400 FALSE city 2743000 Minneapolis, MN
#> 36 0.63059 0.779 TRUE city 2743000 Minneapolis, MN
#> 37 0.37337 0.425 FALSE city 2743000 Minneapolis, MN
#> 38 0.81277 0.637 FALSE city 2743000 Minneapolis, MN
#> 39 0.71518 0.802 TRUE city 2743000 Minneapolis, MN
#> 40 1.04025 1.264 FALSE city 2743000 Minneapolis, MN
#> 41 0.32665 0.378 FALSE city 2743000 Minneapolis, MN
#> geo_mo baseline_pop
#> 1 null total_pop
#> 2 null total_pop
#> 3 null total_pop
#> 4 null total_pop
#> 5 null under18_pop
#> 6 null under18_pop
#> 7 null under18_pop
#> 8 null under18_pop
#> 9 null under18_pop
#> 10 null under18_pop
#> 11 null under18_pop
#> 12 null under18_pop
#> 13 null under18_pop
#> 14 null pov_pop
#> 15 null pov_pop
#> 16 null pov_pop
#> 17 null pov_pop
#> 18 null pov_pop
#> 19 null pov_pop
#> 20 null pov_pop
#> 21 null pov_pop
#> 22 null pov_pop
#> 23 null pov_pop
#> 24 null pov_pop
#> 25 null pov_pop
#> 26 null pov_pop
#> 27 null total_pop
#> 28 null total_pop
#> 29 null total_pop
#> 30 null total_pop
#> 31 null total_pop
#> 32 null total_pop
#> 33 null total_pop
#> 34 null total_pop
#> 35 null total_pop
#> 36 null total_pop
#> 37 null total_pop
#> 38 null total_pop
#> 39 null total_pop
#> 40 null total_pop
#> 41 null total_pop
The Spatial Equity Data Tool has comprehensive documentation in the form
of an online book.
Most notably, there is a chapter specifically devoted to the
API.
It provides more in-depth sedtR
code and outputs.
Other particularly relevant chapters cover common API errors and warnings, how to interpret Tool results, and a description of data appropriate for the Tool.
call_sedt_api()
returns a list object that contains a sf
object
storing the geographic disparity scores:
sedt_response$geo_bias_data |>
head()
#> Simple feature collection with 6 features and 25 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: -93.3195 ymin: 45.01316 xmax: -93.22686 ymax: 45.05125
#> Geodetic CRS: WGS 84
#> sig_diff_seniors data_prop diff_cb_renter_hh diff_pop prop_children
#> 1 TRUE 0.00000 0.000 -0.008 0.01043
#> 2 FALSE 0.00506 -0.004 -0.007 0.01378
#> 3 TRUE 0.00000 -0.002 -0.008 0.00746
#> 4 TRUE 0.00000 -0.003 -0.011 0.01193
#> 5 TRUE 0.00000 0.000 -0.008 0.00486
#> 6 FALSE 0.00253 -0.002 -0.002 0.00533
#> diff_no_internet diff_under_200_poverty_line GEOID diff_pov
#> 1 -0.006 -0.008 27053000101 -0.003
#> 2 -0.008 -0.010 27053000102 -0.005
#> 3 -0.007 -0.006 27053000300 -0.007
#> 4 -0.007 -0.009 27053000601 -0.005
#> 5 -0.006 -0.002 27053000603 -0.002
#> 6 0.001 -0.002 27053001100 -0.001
#> diff_seniors diff_children prop_under_200_poverty_line prop_cb_renter_hh
#> 1 -0.007 -0.010 0.00809 0.00049
#> 2 -0.004 -0.009 0.01458 0.00937
#> 3 -0.008 -0.007 0.00563 0.00158
#> 4 -0.015 -0.012 0.00855 0.00316
#> 5 -0.007 -0.005 0.00243 0.00024
#> 6 0.000 -0.002 0.00517 0.00487
#> prop_no_internet prop_pop geometry prop_pov
#> 1 0.00552 0.00786 MULTIPOLYGON (((-93.3195 45... 0.00345
#> 2 0.01252 0.01152 MULTIPOLYGON (((-93.29919 4... 0.01036
#> 3 0.00728 0.00753 MULTIPOLYGON (((-93.31879 4... 0.00721
#> 4 0.00735 0.01091 MULTIPOLYGON (((-93.26411 4... 0.00515
#> 5 0.00622 0.00761 MULTIPOLYGON (((-93.23712 4... 0.00160
#> 6 0.00198 0.00493 MULTIPOLYGON (((-93.24748 4... 0.00384
#> prop_seniors sig_diff_cb_renter_hh sig_diff_children sig_diff_pop
#> 1 0.00684 FALSE TRUE TRUE
#> 2 0.00938 FALSE TRUE TRUE
#> 3 0.00799 FALSE TRUE TRUE
#> 4 0.01453 FALSE TRUE TRUE
#> 5 0.00700 FALSE TRUE TRUE
#> 6 0.00330 FALSE FALSE TRUE
#> sig_diff_no_internet sig_diff_pov disp_name
#> 1 FALSE FALSE Census Tract 1.01, Minneapolis, MN
#> 2 FALSE FALSE Census Tract 1.02, Minneapolis, MN
#> 3 FALSE TRUE Census Tract 3, Minneapolis, MN
#> 4 TRUE TRUE Census Tract 6.01, Minneapolis, MN
#> 5 TRUE FALSE Census Tract 6.03, Minneapolis, MN
#> 6 FALSE FALSE Census Tract 11, Minneapolis, MN
#> sig_diff_under_200_poverty_line weighted_counts
#> 1 TRUE 0
#> 2 TRUE 2
#> 3 TRUE 0
#> 4 TRUE 0
#> 5 TRUE 0
#> 6 FALSE 1
A data frame with demographic information used in the analysis is also returned:
sedt_response$demo_bias_data |>
head()
#> census_var data_value summary_value diff_data_city
#> 1 pct_no_internet 8.78435 7.752 1.03235
#> 2 pct_under_200_poverty_line 37.70731 33.240 4.46731
#> 3 pct_all_other_races 6.23852 6.280 -0.04148
#> 4 pct_less_hs_diploma 10.10677 9.295 0.81177
#> 5 pct_under18_unins 4.50332 3.074 1.42932
#> 6 pct_under18_pov 19.22721 21.193 -1.96579
#> data_value_sd summary_value_margin sig_diff geo geo_fips geo_display
#> 1 0.54109 0.508 FALSE city 2743000 Minneapolis, MN
#> 2 0.74891 0.955 TRUE city 2743000 Minneapolis, MN
#> 3 0.32612 0.395 FALSE city 2743000 Minneapolis, MN
#> 4 0.62023 0.532 FALSE city 2743000 Minneapolis, MN
#> 5 1.49243 0.495 FALSE city 2743000 Minneapolis, MN
#> 6 2.10830 1.697 FALSE city 2743000 Minneapolis, MN
#> geo_mo baseline_pop
#> 1 null total_pop
#> 2 null total_pop
#> 3 null total_pop
#> 4 null total_pop
#> 5 null under18_pop
#> 6 null under18_pop
The package has under-development visualization functions create_map()
and create_demo_chart()
that ultimately will be able to visualize
these results in graphics similar to those displayed on the SEDT
website.
The Spatial Equity Data Tool has comprehensive documentation in the form
of an online book.
Most notably, there is a chapter specifically devoted to the
API.
It provides more in-depth sedtR
code and outputs.
Other particularly relevant chapters cover common API errors and warnings, how to interpret Tool results, and a description of data appropriate for the Tool.
Please provide feedback by opening GitHub Issues or contacting us at sedt@urban.org.