sean-mcclure / covid19.js

The covid19.js library can be used to create web applications based off covid19 data.
https://collaboratescience.com/corona/
1 stars 1 forks source link

Roll up counties by FIPS codes? #2

Open davidbau opened 4 years ago

davidbau commented 4 years ago

JHU provides FIPS codes for counties. Can you support that information as well?

sean-mcclure commented 4 years ago

JHU provides FIPS codes for counties. Can you support that information as well?

Do you just want to bring back the FIPS code for a searched county, or do you want to get the time series and reports data for the searched county?

davidbau commented 4 years ago

covid.get_time_series("cumulative", "cases", "California")

The functionality I want to support what's on covid19chart.org. It currently depends on a JHU loading data layer as well as a CDS loading solution, but I'm looking around for an alternative that allows me not to depend on them directly since JHU has been unstable in the past. Although the user interface does not provide access to counties by FIPS yet, the underlying data layer does, and the user interface will depend on FIPS soon.

The ideal data API would allow (1) fast retrieval of about a batch of summed time series at once (if retrieving one at a time is slow). For example, given a function that maps f(country, state, county, fips) -> (string key or null)

On Sun, Mar 29, 2020 at 4:08 PM Sean McClure notifications@github.com wrote:

JHU provides FIPS codes for counties. Can you support that information as well?

Do you just want to bring back the FIPS code for a searched county, or do you want to get the time series and reports data for the searched county?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sean-mcclure/covid19.js/issues/2#issuecomment-605692800, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2MN2DIMILBCLA3KXBBP2LRJ6TEPANCNFSM4LWC7VLQ .

sean-mcclure commented 4 years ago

@davidbau I have added FIPS level support to the library.

You can get multiple time series in a single call by running covid.get_time_series_multiple:

example covid.get_time_series_multiple("cumulative", "cases", ["Germany", "Italy", "France", "United Kingdom"])

This will support country, region and FIPS level data. Thus, if you know the list of FIPS you want to fetch:

example covid.get_time_series_multiple("cumulative", "cases", ["40099", "40101", "40103", "40105"])

output

40099: []
40101: (7) [{…}, {…}, {…}, {…}, {…}, {…}, {…}]
40103: (7) [{…}, {…}, {…}, {…}, {…}, {…}, {…}]
40105: [{…}]

Note that not all fips return time series. Either they are not in the original data source (usually the case), or the coviddata repo is missing some data. I have raised an issue with them as I already noticed some missing fips data.

You can also get summed totals across multiple time series by running covid.get_time_series_multiple_sum:

example covid.get_time_series_multiple_sum("cumulative", "cases", ["Germany", "Italy", "France", "United Kingdom"])

output

{
    2020-01-28: 8,
    2020-01-29: 9,
    2020-01-30: 9,
    2020-01-31: 14,
    2020-02-01: 18,
    ...
}

This will obviously work for fips as well.

There are other utility methods related to fips you can check out on this repo. Let me know if you have any issues.