MODERATOR NOTE: coronavirus resources & updates: https://wolfr.am/coronavirus
-- you have earned Featured Contributor Badge
Your exceptional post has been selected for our editorial column Staff Picks http://wolfr.am/StaffPicks and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you!
It appears that Which[] should be replaced by Which@@.
Good catch! The notebook is revised. Tnx!
Hi Mads,
I made a copy of your notebook in my cloud account. When I run it I get
Which::argctu: Which called with 1 argument.
Looks like the definition of cfunc is not right.
cfunc
Hmmm, I tried on cloud, and it works fine. On cloud, click on "Evaluation", then "Quit Kernel", and then "Evaluate All Cells".
I made a copy before you fixed the issue with Which. Latest version works fine. Thanks!
Which
I added the following code to show data for any state using Manipulate.
Manipulate
cases[state_] := ResourceData["Epidemic Data for Novel Coronavirus COVID-19", "USCounties"][ Select[#State == state &], {#County, #ConfirmedCases["LastValue"]} &] // Normal; Manipulate[ GeoRegionValuePlot[Rule @@@ cases[state], GeoLabels -> (Tooltip[#1, Column[{First@CanonicalName@#2, #4}]] &), ColorFunction -> cfunc, ColorFunctionScaling -> False, PlotLegends -> legend, PlotLabel -> "COVID19 cases in " <> First@CanonicalName@state, ImageSize -> Large], {state, EntityClass["AdministrativeDivision", "USStatesAllStates"] // EntityList, ControlType -> PopupMenu}]
I believe there is something wrong with the way GeoRegionValuePlot is displaying colors for some counties. For example if you look at Sonoma county, the confirmed cases is 192 (as of 4/23/2020), but the color doesn't match. There are other counties that show the same issue. Can you explain this?
Thanks @David G . I will resolve the issue soon (very busy workload today). Quick solution for now:
Legended[GeoGraphics[{EdgeForm[ Black], {GeoStyling[cfunc[#2]], Tooltip[Polygon[#1], Column[{StringDelete[CommonName[#1], ", California, United States"], #2}]]} & @@@ coCases}, PlotLabel -> "COVID19 cases in California", ImageSize -> Large], legend]
It is a bug, reported and hopefully will be resolved soon. So color functions and etc in my codes are good.I revised the notebook accordingly
Thanks for the workaround, @Mads Bahrami!