cenpy-devs / cenpy

Explore and download data from Census APIs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Update ACS offering (special case for 2020 geographies)

jbousquin opened this issue · comments

With PR #127 to dynamically update layers most ACS updates will only need an update to the years supported (3 lines), i.e., for 2020;

    def __init__(self, year="latest"):
        self._cache = dict()
        if year == "latest":
            year = 2020
        if year not in list(range(2017,2021)):
            raise NotImplementedError(
                "The requested year ({}) is too early/late. "
                "Only 2017, 2018, 2019 or 2020 are supported.".format(year)
            )

However, because ACS 2020 does not have it's own tiger MapService it's a special case and needs additional handling to redirect it to the 2020 census geographies. This could be in products, remote or tiger so it may merit discussion. My preference is remote where self.mapservice is assigned, e.g.,:

        if isinstance(key, tig.TigerConnection):
            self.mapservice = key
        elif isinstance(key, str):
            if key == 'tigerWMS_ACS2020':
                # No unique layer use census 2020 geographies
                self.mapservice = tig.TigerConnection(name='tigerWMS_Census2020')
            else:
                self.mapservice = tig.TigerConnection(name=key)
        return self

Open to more elegant solution than above, but should work.

Is this true for 2021 ACS as well?

Only 2020 will be a special case. ACS 2021 and 2022 geographies are available and should work with the dynamic layer PR so just the years have to be updated once the data is available (5-year ACS 2021 is scheduled for December).

Confirmed - PR #127 works as intended for the recently released 5-year 2021 vintage:

    def __init__(self, year="latest"):
        self._cache = dict()
        if year == "latest":
            year = 2021
        if year not in list(range(2017,2022)):
            raise NotImplementedError(
                "The requested year ({}) is too early/late. "
                "Only 2017, 2018, 2019, 2020, or 2021 are supported.".format(year)
            )