Skip to content

Commit 0571321

Browse files
committed
fix timezone data to not have edges outside a valid lon/lat range
1 parent 06cd450 commit 0571321

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

data-raw/timezones.R

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@ unzip("data-raw/timezones.zip", exdir = "data-raw/timezones")
1111
# this won't preserve topology...when this is possible with S2, this should be updated
1212
tz <- read_sf("data-raw/timezones/ne_10m_time_zones.shp", check_ring_dir = TRUE) %>%
1313
st_set_crs(NA) %>%
14+
# don't get too close to the poles
15+
st_intersection(sf::st_as_sfc(wk::rct(-179.9, -89.9, 179.9, 89.9))) %>%
1416
st_simplify(dTolerance = 1e-2) %>%
1517
st_set_crs(4326)
1618

1719
# there's one invalid ring in feature 30 that has to get nixed
1820
# to load into S2
1921
tz$geometry[[30]] <- st_multipolygon(tz$geometry[[30]][1])
2022

23+
tz$geometry <- tz$geometry %>%
24+
lwgeom::st_geod_segmentize(units::set_units(1e3, "km"))
25+
2126
tz_wkb <- st_as_binary(tz$geometry, EWKB = TRUE)
2227

2328
s2_data_tbl_timezones <- as.data.frame(
@@ -28,7 +33,7 @@ s2_data_tbl_timezones <- as.data.frame(
2833
)
2934

3035
# make sure this will load into S2
31-
s2 <- s2::as_s2_geography(s2_data_tbl_timezones$geometry)
36+
s2 <- s2::s2_geog_from_wkb(s2_data_tbl_timezones$geometry, check = TRUE)
3237
s2_wkb <- s2::s2_as_binary(s2)
3338

3439
usethis::use_data(s2_data_tbl_timezones, overwrite = TRUE)

data/s2_data_tbl_timezones.rda

9.37 KB
Binary file not shown.

0 commit comments

Comments
 (0)