Function Resource

GoogleMobilityReport

Generate a dataset from Google Community Mobility Reports for a given country

ResourceFunction["GoogleMobilityReport"][type]

generate a dataset according to type from Google Community Mobility Reports.

Details and Options

The argument type can be a string (name of a country or its ISO 3166-1 alpha-2 code) or an Entity of the type as "Country".
ResourceFunction["GoogleMobilityReport"][type] generates a dataset from the Google reports on movement trends over time by geography, across different categories of places such as retail and recreation, groceries and pharmacies, parks, transit stations, workplaces, and residential.
The mobility reports are given as TimeSeries for different categories such as retail and recreation, groceries and pharmacies, parks, transit stations, workplaces, and residential..
The properties (column names) of the dataset are as follows:
"Country"The corresponding country
"SubRegion1"Level 1 administrative divisions within a country (e.g., US states)
"SubRegion2"Level 2 administrative divisions of an administrative division of level 1 (e.g., US counties)
"MetroArea"Corresponding metropolitan areas, if any
"RetailAndRecreation"Mobility trends for places like restaurants, cafes, shopping centers, theme parks, museums, libraries, and movie theaters.
"GroceryAndPharmacy"Mobility trends for places like grocery markets, food warehouses, farmers markets, specialty food shops, drug stores, and pharmacies.
"Parks"Mobility trends for places like local parks, national parks, public beaches, marinas, dog parks, plazas, and public gardens.
"TransitStations"Mobility trends for places like public transport hubs such as subway, bus, and train stations.
"Workplaces"Mobility trends for places of work.
"Residential"Mobility trends for places of residence.
According to the Google documentation on this data, changes for each day are compared to a baseline value for that day of the week. The baseline is the median value, for the corresponding day of the week, during the 5-week period Jan 3–Feb 6, 2020.

Examples

Basic Examples (3) 

Get the data of Italy:

ProgressIndicator is used and Echo is removed. A temporary message, showing the progress, is shown and disappears once done

In[1]:=
it = ResourceFunction[
   "https://www.wolframcloud.com/obj/mohammadb/DeployedResources/\
Function/GoogleMobilityReport"]["IT"];

A peak into three random rows of dataset:

In[2]:=
it[RandomInteger[Length[it], 3]]
Out[2]=

Visualize the data for the city of Rome:

In[3]:=
Multicolumn[
 KeyValueMap[
   DateListPlot[{#2}, PlotLabel -> #1, Sequence[
     Joined -> {True, False}, Filling -> {1 -> Axis, 2 -> {Axis, 
Directive[
Opacity[0.5], Red, Thick]}}, AspectRatio -> 1/2, FrameTicks -> {{{{-80, "-80%"}, {-40, "-40%"}, {
          0, "Baseline"}, {40, "+40%"}, {80, "+80%"}}, None}, Automatic}, ImageSize -> Medium, GridLines -> {None, {-80, -40, 0, 40, 80}}, PlotStyle -> {Automatic, None}, PlotRange -> {-100, 100}]] &][
  rome = Normal[
     it[SelectFirst[#SubRegion2 == "Metropolitan City of Rome" &]]][[-6 ;;]]], 3]
Out[3]=

Possible Issues (1) 

Google reports do not contain all countries:

In[4]:=
ResourceFunction[
 "https://www.wolframcloud.com/obj/mohammadb/DeployedResources/\
Function/GoogleMobilityReport"]["Iran"]
Out[4]=

The data wrangling of some countries with many subregions (e.g., USA) may be a time consuming process.

Neat Examples (1) 

It is usually said that the North and South of Italy are very different. Compare the mobility reports of Northern Italy (Nord) vs Southern Italy (Mezzogiorno) in different categories:

In[5]:=
Table[DateListPlot[
  MovingAverage[#, 7] & /@ Mean /@ Map[DeleteMissing, Values /@ Through[{KeyTake[{
          "Aosta", "Liguria", "Lombardy", "Emilia-Romagna", "Veneto", "Trentino-South Tyrol", "Friuli-Venezia Giulia"}], KeyDrop[{
          "Aosta", "Liguria", "Lombardy", "Emilia-Romagna", "Veneto", "Trentino-South Tyrol", "Friuli-Venezia Giulia"}]}[
        category[i]]], {2}], PlotRange -> All, PlotLegends -> Placed[{"Nord", "Mezzogiorno"}, {Right, Top}], PlotLabel -> i, ImageSize -> Medium], {i, {
  "RetailAndRecreation", "GroceryAndPharmacy", "Parks", "TransitStations", "Workplaces", "Residential"}}]
Out[5]=

Source Metadata