Skip to content

sle_adm3: regenerate the stored object so validTo is NA - #49

Merged
Lfquezada merged 2 commits into
mainfrom
fix-sle-adm3-validto
Sep 7, 2026
Merged

Lfquezada merged 2 commits into
mainfrom
fix-sle-adm3-validto

Conversation

@raubreywhite

Copy link
Copy Markdown
Contributor

Fixes #48.

get_data(name = "sle_adm3") returned validTo = -1-11-30 in all 167 rows; the shapefile field is empty (NA). The stored .rda had been built with an older GDAL that wrote a sentinel for the empty date. This PR rebuilds data/sle_adm3.rda from inst/extdata/sle_adm3.zip with the existing data-raw/sle_adm3.R under sf 1.1.1 / GDAL 3.4.1, so the object equals sf::read_sf() on the zip in every column (names, 167 rows, classes, CRS, geometry). Old and new differ in that one column only.

A sweep of all 103 stored datasets (210 Date/POSIXct columns, plus the nested epinow, stars and phylo objects) found no other pre-1900 date; sle_hf, Blocksshape, Quartiersshape and gis_africa_countries carry no date columns.

Version 0.0.0.9013 and a NEWS entry. No code change.

Check after install:

x <- appliedepidata::get_data(name = "sle_adm3")
all(is.na(x$validTo))   # TRUE
nrow(x)                 # 167

Downstream: the Epidemiologist R Handbook's GIS chapter switch to get_data() (appliedepi/epirhandbook#446) waits on this, followed by a pin bump in aedockerpublic (appliedepi/aedockerpublic#2).

data/sle_adm3.rda carried validTo = -1-11-30 in all 167 rows, a sentinel an older GDAL wrote for the shapefile's empty date field. Rebuilt from inst/extdata/sle_adm3.zip with data-raw/sle_adm3.R under sf 1.1.1 / GDAL 3.4.1; the object now equals sf::read_sf() on the zip in every column. A sweep of all 103 stored datasets (210 Date/POSIXct columns and the nested objects) found no other pre-1900 date. Version 0.0.0.9013, NEWS entry.
@Lfquezada

Copy link
Copy Markdown
Contributor

@raubreywhite The fix worked, but only by accident: it was built once under an old GDAL version, and the data-raw/sle_adm3.R script itself didn't actually handle the sentinel (so re-running it on a newer GDAL (like on my computer) reproduced the original bug.

I patched data-raw/sle_adm3.R to explicitly convert any implausible pre-1900 date to NA, regardless of GDAL version, then regenerated data/sle_adm3.rda from that fixed script (the data itself didn't change, it's just now reproducible).

Bumped up the version of the data in the tableoftables.xlsx as well!

The ID now would be ebola_outbreak_sle_2014_shape_1_2

Tested on my computer and looks fine! @jarvisc1 Ill merge now and update the package to V0.0.0.9013

@Lfquezada
Lfquezada merged commit 77036b1 into main Sep 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sle_adm3: validTo holds a year -1 sentinel date instead of NA (blocks the handbook GIS chapter's get_data() switch)

2 participants