mountainMath / cancensus

R wrapper for calling CensusMapper APIs
https://mountainmath.github.io/cancensus/index.html
Other
82 stars 15 forks source link

1996's DAs calls with province region returns an empty dataframe #189

Closed bdbmax closed 2 years ago

bdbmax commented 2 years ago

When retrieving DAs for a whole province with the "CA1996" dataset, the output is an empty dataframe. Other similar calls do work. It seems to only be touching this dataset and level, when retrieving for a whole province:

# DA at the province level returns an empty dataframe
cancensus::get_census(dataset = "CA1996", 
                      regions = list(PR = 24),
                      level = "DA")
# A tibble: 0 × 11
# … with 11 variables: GeoUID <chr>, Type <fct>, Region Name <fct>, Area (sq km) <dbl>, Population <dbl>,
#   Dwellings <dbl>, Households <dbl>, CSD_UID <chr>, CD_UID <chr>, CT_UID <chr>, CMA_UID <chr>
# ℹ Use `colnames()` to see all variable names

# 1996 DA's can get retrieve with a bustitute to `list(PR ...`
cancensus::get_census(dataset = "CA1996", 
                      regions = list(CMA = 24462),
                      level = "DA")
# works

# DA for another year is working
cancensus::get_census(dataset = "CA01", 
                      regions = list(PR = 24),
                      level = "DA")
# works

# CT is working
cancensus::get_census(dataset = "CA1996", 
                      regions = list(PR = 24),
                      level = "CT")
# works
mountainMath commented 2 years ago

That's a bug int he CensusMapper backend, thanks for flagging. There were no DAs in 1996, they got introduced for the first time in 2001. In 1996 (and before) there were Enumeration Areas instead. There is some under-the-hood translation in the backend to allow querying for DAs and subbing in EAs, which did not work properly. Should be fixed now, try it again with the use_cache = FALSE option in the call.

bdbmax commented 2 years ago

Works great. Thanks a bunch!