chazeon / NYState-COVID-19-Tracker

COVID-19 positive cases tracker for New York State.
MIT License
14 stars 5 forks source link

KeyError in extract_color_nyc.py #1

Closed jpwright closed 4 years ago

jpwright commented 4 years ago

Running make update today, I got the following error:

python3 scripts/extract_map_nyc.py
Traceback (most recent call last):
  File "scripts/extract_map_nyc.py", line 18, in <module>
    dataset = get_map_dataset("documents/NYC-covid-19-data-map")
  File "scripts/extract_map_nyc.py", line 13, in get_map_dataset
    map_dataset.append(extract_map_data(dir_from / fname))
  File "/media/jason/e/projects/covid19/NYState-COVID-19-Tracker/scripts/util/extract_map_nyc.py", line 69, in extract_data
    for neighbor_code, severity in extract_pdf_data(fname):
  File "/media/jason/e/projects/covid19/NYState-COVID-19-Tracker/scripts/util/extract_color_nyc.py", line 44, in extract_pdf_data
    yield k, color_map[data[k]]
KeyError: (179, 205, 226)
make: *** [Makefile:33: update-pdf] Error 1

I'm guessing it has something to do with the color scheme of the DOH maps changing from orange to purple: https://www1.nyc.gov/assets/doh/downloads/pdf/imm/covid-19-data-map.pdf

chazeon commented 4 years ago

This is actually not the problem with the color scheme, the problem is they are now sharing the data in terms of zip code district instead of "UHF neighborhood". The data point coordinates according to which the color is sampled is selected according to the previous criteria.

I am temporarily avoiding using this script and pondering whether there is the need to update the code/data because nycHealth are now sharing more detailed data in the official GitHub repo, in terms of zip code district.

chazeon commented 4 years ago

If you indeed want to use this script, you need to prepare a new coordinates file like this: https://github.com/chazeon/NYState-COVID-19-Tracker/blob/master/data/test_map_coords.json which is originally generated using the WebPlotDigitizer.