-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest-cincy_geographies.R
98 lines (84 loc) · 2.94 KB
/
test-cincy_geographies.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
test_that("cincy zcta works", {
d <- cincy_zcta_geo("2024")
expect_equal(names(d), c("geoid", "s2_geography"))
expect_s3_class(d, c("sf", "tbl_df"))
expect_equal(nrow(d), 55L)
expect_equal(round(sum(s2::s2_area(d$s2_geography)), -3), 1083637000L)
d <- cincy_zcta_geo("2019")
expect_equal(names(d), c("geoid", "s2_geography"))
expect_s3_class(d, c("sf", "tbl_df"))
expect_equal(nrow(d), 54L)
expect_equal(round(sum(s2::s2_area(d$s2_geography)), -3), 1089190000L)
})
test_that("cincy tracts and block groups", {
d <- cincy_census_geo("tract", "2024")
expect_equal(nrow(d), 226)
expect_s3_class(d, c("sf", "tbl_df"))
expect_s3_class(d$s2_geography, "sfc")
expect_true(is.character(d$geoid))
d <- cincy_census_geo("tract", "2019")
expect_equal(nrow(d), 222)
expect_s3_class(d, c("sf", "tbl_df"))
expect_s3_class(d$s2_geography, "sfc")
expect_true(is.character(d$geoid))
d <- cincy_census_geo("bg", "2024")
expect_equal(nrow(d), 678)
expect_s3_class(d, c("sf", "tbl_df"))
expect_s3_class(d$s2_geography, "sfc")
expect_true(is.character(d$geoid))
d <- cincy_census_geo("bg", "2019")
expect_equal(nrow(d), 697)
expect_s3_class(d, c("sf", "tbl_df"))
expect_s3_class(d$s2_geography, "sfc")
expect_true(is.character(d$geoid))
})
test_that("geography functions will error for years outside of 2013 - 2024", {
cincy_census_geo("tract", "2012") |>
expect_error("must be one of")
cincy_county_geo("2012") |>
expect_error("must be one of")
})
test_that("cincy county", {
d <- cincy_county_geo("2024")
expect_equal(length(d), 1)
expect_s3_class(d, c("s2_geography", "wk_vctr"))
expect_equal(round(s2::s2_area(d), -3), 1067800000)
})
test_that("cincy city", {
d <- cincy_city_geo()
expect_equal(length(d), 1)
expect_s3_class(d, c("s2_geography", "wk_vctr"))
expect_equal(round(s2::s2_area(d), -3), 206352000L)
})
test_that("cincy zcta", {
d <- cincy_zcta_geo("2024")
expect_equal(nrow(d), 55)
expect_s3_class(d, c("sf", "tbl_df"))
expect_s3_class(d$s2_geography, "sfc")
expect_true(is.character(d$geoid))
d <- cincy_zcta_geo("2018")
expect_equal(nrow(d), 54)
expect_s3_class(d, c("sf", "tbl_df"))
expect_s3_class(d$s2_geography, "sfc")
expect_true(is.character(d$geoid))
})
test_that("cincy neighborhoods", {
d <- cincy_neighborhood_geo("statistical_neighborhood_approximations")
expect_equal(nrow(d), 50)
expect_s3_class(d, c("sf", "tbl_df"))
expect_s3_class(d$s2_geography, "sfc")
expect_true(is.character(d$geoid))
d <- cincy_neighborhood_geo("community_council")
expect_equal(nrow(d), 75)
expect_s3_class(d, c("sf", "tbl_df"))
expect_s3_class(d$s2_geography, "sfc")
expect_true(is.character(d$geoid))
})
test_that("cincy addresses", {
d <- cincy_addr_geo()
expect_s3_class(d, c("sf", "tbl_df"))
expect_s3_class(d$s2_geography, "sfc")
expect_true(is.character(d$cagis_address))
expect_true(is.character(d$cagis_parcel_id))
expect_true(is.logical(d$cagis_is_condo))
})