All Projects → datasciencecampus → Mobius

datasciencecampus / Mobius

Licence: mit
Scripts to extract data from the COVID-19 Google Community Mobility Reports

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Mobius

Svglib
Read SVG files and convert them to other formats.
Stars: ✭ 139 (+195.74%)
Mutual labels:  svg, pdf
Latexdraw
A vector drawing editor for LaTeX (JavaFX).
Stars: ✭ 336 (+614.89%)
Mutual labels:  svg, pdf
Pyecharts Snapshot
renders the output of pyecharts as png, jpeg, gif, svg, eps, pdf and raw base64
Stars: ✭ 142 (+202.13%)
Mutual labels:  svg, pdf
Official Bash Logo
Everything you need to start using the official GNU Bash logo
Stars: ✭ 89 (+89.36%)
Mutual labels:  svg, pdf
Libvips
A fast image processing library with low memory needs.
Stars: ✭ 6,094 (+12865.96%)
Mutual labels:  svg, pdf
I7j Pdfhtml
pdfHTML is an iText 7 add-on for Java that allows you to easily convert HTML and CSS into standards compliant PDFs that are accessible, searchable and usable for indexing.
Stars: ✭ 104 (+121.28%)
Mutual labels:  svg, pdf
Deck
Slide Decks
Stars: ✭ 261 (+455.32%)
Mutual labels:  svg, pdf
Php Svg Lib
SVG file parsing / rendering library
Stars: ✭ 1,146 (+2338.3%)
Mutual labels:  svg, pdf
Cairosvg
Convert your vector images
Stars: ✭ 453 (+863.83%)
Mutual labels:  svg, pdf
Rust Skia
Safe Skia Bindings for Rust
Stars: ✭ 450 (+857.45%)
Mutual labels:  svg, pdf
Vectorgraphics2d
Graphics2D implementations to export various vector file formats
Stars: ✭ 87 (+85.11%)
Mutual labels:  svg, pdf
Itext7 Dotnet
iText 7 for .NET is the .NET version of the iText 7 library, formerly known as iTextSharp, which it replaces. iText 7 represents the next level of SDKs for developers that want to take advantage of the benefits PDF can bring. Equipped with a better document engine, high and low-level programming capabilities and the ability to create, edit and enhance PDF documents, iText 7 can be a boon to nearly every workflow.
Stars: ✭ 698 (+1385.11%)
Mutual labels:  svg, pdf
Dicom Ecg Plot
Dicom ECG Viewer and Converter. Convert to PDF, PNG, JPG, SVG, ...
Stars: ✭ 84 (+78.72%)
Mutual labels:  svg, pdf
Dvisvgm
A fast DVI, EPS, and PDF to SVG converter
Stars: ✭ 134 (+185.11%)
Mutual labels:  svg, pdf
Maker.js
📐⚙ 2D vector line drawing and shape modeling for CNC and laser cutters.
Stars: ✭ 1,185 (+2421.28%)
Mutual labels:  svg, pdf
Svg2pdf.js
A javascript-only SVG to PDF conversion utility that runs in the browser. Brought to you by yWorks - the diagramming experts
Stars: ✭ 231 (+391.49%)
Mutual labels:  svg, pdf
Openhtmltopdf
An HTML to PDF library for the JVM. Based on Flying Saucer and Apache PDF-BOX 2. With SVG image support. Now also with accessible PDF support (WCAG, Section 508, PDF/UA)!
Stars: ✭ 1,096 (+2231.91%)
Mutual labels:  svg, pdf
Govips
A lightning fast image processing and resizing library for Go
Stars: ✭ 442 (+840.43%)
Mutual labels:  svg, pdf
Html Pdf Chrome
HTML to PDF converter via Chrome/Chromium
Stars: ✭ 629 (+1238.3%)
Mutual labels:  google, pdf
Itext7
iText 7 for Java represents the next level of SDKs for developers that want to take advantage of the benefits PDF can bring. Equipped with a better document engine, high and low-level programming capabilities and the ability to create, edit and enhance PDF documents, iText 7 can be a boon to nearly every workflow.
Stars: ✭ 913 (+1842.55%)
Mutual labels:  svg, pdf

mobius - Mobility Report graph extractor

PLEASE READ: As of 16/04/2020 Google have released the data in CSV format. This tool will not be maintained going forward.

Logo

For extracting every graph from any Google's COVID-19 Community Mobility Report (182) into comma separated value (CSV) files. This code is developed at speed on the COVID-19 Community Mobility Report PDF documents published on Friday 3rd of April 2020.

Updates

10/04/2020: PDF and SVGs updated for the Friday 10th of April 2020 release of data. 16/04/2020: PDF and SVGs updated for the Wednesday 15th of April 2020 release of data.

Installation

We provide the python requirements.txt file as well as a poetry setup for dependency management.

We recommend using a virtual environment before installing dependencies.

To install with pip:

pip install -r requirements.txt

To install with poetry

poetry install

External Dependencies

This project uses Rtree which in turn depends on spatialindex.

On OSX this can require separate installation: brew install spatialindex

Usage

TLDR:

# Check what report dates are available
python ./mobius.py dt

# Check if a country is available, with an option to select a date (not specifying a date will show all results)
python ./mobius.py ls <DATE>

# Download PDF and SVG
python ./mobius.py download <COUNTRY_CODE> <DATE>

# Process the PDF and SVG
python ./mobius.py summary <INPUT_PDF> <OUTPUT_FOLDER> <DATES_FILE>
python ./mobius.py full <INPUT_PDF> <INPUT_SVG> <OUTPUT_FOLDER> <DATES_FILE>

Note: DATE_FILE refers to the look up file in the config directory named dates_lookup_xxxx_xx_xx.csv where the x mark the release date of the reports you are extracting the data from.

Full command list

Usage: mobius.py [OPTIONS] COMMAND [ARGS]...

  Downloader and processor for Google mobility reports

Options:
  --help  Show this message and exit.

Commands:
  download  Download pdf and svg for a given country using the country code
  dt        List all the dates reports are available for
  full      Produce full CSV of trend data from PDF/SVG input
  pdf       List all the PDFs available in the buckets
  proc      Process a given country SVG
  summary   Produce summary CSV of regional headline figures from CSV
  svg       List all the SVGs available in the buckets
  
  1. Check what dates reports are available for using mobius.py dt command:

    Usage: mobius.py dt
    
      List the dates reports are available for
    
    Options:
      --help  Show this message and exit.
    
  2. Check for, and download, SVG and PDF files using mobius.py svg and mobius.py download commands:

    Use the mobius.py command line tool to list all the available countries for PDF/SVG and then download them with the two helpful commands below.

    Usage: mobius.py svg [OPTIONS][DATE]
    
      List the SVGs available in the buckets for the given date. If no date given, a list of all available SVGs is returned
    
    Options:
      --help  Show this message and exit.
      <DATE> Lists all the SVGs published on the date
    
    
    Usage: mobius.py pdf [OPTIONS] [DATE]
    
      List the PDFs available in the buckets for the given date. If no date given, a list of all available PDFs is returned
    
    Options:
      --help  Show this message and exit.
    
    
    Usage: mobius.py download [OPTIONS] COUNTRY_CODE [DATE]
    
      Download PDF and SVG for a given country using the country code and date. If no DATE argument given all available PDFs and SBGs for the given country will be downloaded
    
    Options:
      --help  Show this message and exit.
    
  3. Run the mobius.py summary command

    Usage: mobius.py summary [OPTIONS] INPUT_PDF OUTPUT_FOLDER DATES_FILE
    
      Produce summary CSV of regional headline figures from CSV
    
    Options:
      --help  Show this message and exit.
    

Specify the input pdf file for the individual country as the INPUT_PDF, and the output folder where you want the CSV to (e.g. ./output).

Creates a summary CSV joined to the data extracted from the SVG plots <OUTPUT_FOLDER>/<INPUT_PDF_BASENAME>_summary.csv.

  1. Run the mobius.py full command
    Usage: mobius.py full [OPTIONS] INPUT_PDF INPUT_SVG OUTPUT_FOLDER DATES_FILE
    
      Produce full CSV of trend data from PDF/SVG input
    
    Options:
      --help                 Show this message and exit.
      
    

Specify the input pdf/svg file for the individual country as the INPUT_PDF/INPUT_SVG, and the output folder where you want the CSV to be saved to (e.g. ./output).

Pass in a custom the dates lookup file (e.g. ./config/dates_lookup_<date>.csv) - used to convert coordinates to dates. <date> is in the YYYY_MM_DD format and all available dates for download are available using mobius dt command.

Creates a full CSV joined to the data extracted from the SVG plots <OUTPUT_FOLDER>/<INPUT_PDF_BASENAME>.csv.

Command gives a short summary of any discrepancies between the summary figures and the data extracted from svg plots.

  1. (Alternative) Run the mobius.py proc command

    Usage: mobius.py proc [OPTIONS] INPUT_LOCATION OUTPUT_FOLDER [DATES_FILE]
    
      Process a given country SVG
    
    Options:
      -f, --folder TEXT  If provided will overwrite the output folder name
      -s, --svgs         Enables saving of SVGs that get extracted
      -c, --csvs         Enables saving of CSVs that get extracted
      -p, --plots        Enables creation and saving of additional PNG plots
      --help             Show this message and exit.
    

Specify the input file for the individual country as the INPUT_LOCATION and the output folder where you want the CSV and other files to be saved to (e.g. ./output).

Optionally pass in a custom the dates lookup file (e.g. ./config/dates_lookup.csv) - used to convert coordinates to dates.

If you want simple matplotlib PNG plots to save as well as CSV files, use the -p flag.

Data format

Each CSV from proc will be saved to (./output/<COUNTRY_CODE>/csv), starting at 1.csv. As of the COVID-19 Community Mobility Reports released on Friday 3rd April 2020, CSV files 1.csv to 6.csv relate to the country-level graphs in the original PDF (pages one and two). Then each set of 6 CSV files (e.g., 7.csv to 12.csv) will relate to a regional area.

Each set of 6 files follows the order: 1. Retail & recreation 2. Grocery & pharmacy 3. Parks 4. Transit stations 5. Workplaces 6. Residential

G20 CSV Datasets

CSV datasets for G20 countries (except Russia and China) can be found at the Data Science Campus' Google Mobility Reports Data repository.

Creating your own SVG

  1. To create your own SVG from a PDF, we recommend using Affinity Designer. This is because Affinity Designer flattens the SVG, which is required for mobius.py proc. Affinity Designer also closes point features in SVG files, which other programmes do not. Use the following steps:

    1. Load in PDF document to Affinity Designer.
    2. Click Load all pages.
    3. File > Export > SVG (for print) if using version 1.6.3 or File > Export > SVG (digital - high quality) for version 1.8.3
    4. Select Area: Whole Document.
    5. Save the SVG file to (./svgs).

Utility script

To run through all available countries see run_all.sh. See run_all.sh help for usage.

# Create summary and full CSVs for all countries returned by ./mobius.py svg
./run_all.sh

Contributing

Any suggestions or issues, please use the Issues template. We welcome collaborators. To help us with this work, fork the repository and issue a Pull Request when you have added a feature, or fixed a bug. Thanks!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].