opentechinstitute / bq2geojson

A tool to (relatively) easily convert M-Lab BigQuery data into spatially joined GeoJSON files, then integrate them into a Leaflet-based map.
0 stars 4 forks source link

bq2geojson

This repository consists of two parts:

Dependencies

Several Node.js modules are required.

These should be automatically installed in the local directory ./node_modules/ when you run "npm install" later.

You will also need to have the Google Cloud SDK installed. Most importantly, the SDK contains the "bq" command, which is the tool used to query BigQuery. There are versions of the SDK for all major OSs. Once installed, you need to make sure that the "bq" command is in your path.

Getting started

Assuming you already have Node.js and npm installed on your system, and both the "node" and "npm" commands are in your PATH, then the following should get you started:

The script index.js requires a year argument, and of course it must be a year for which M-Lab data exists in BigQuery. You may also pass a series of months, with leading zeros for months with only one number (e.g., 01 03 08 11). If you don't pass any month arguments, then the script assumes you want all twelve months.

By default index.js will create hex-binned GeoJSON files, however you can configure it to use arbitrary polygon files (e.g., city/state districts). The polygon file(s) must be a flat GeoJSON FeatureCollection that Turf.js can understand. The first part of index.js, where user-set variable are configured, has ample comments that hopefully obviate the need to add them here, requiring the need to keep those comments in sync with these.

Using the default configuration, index.js will create three directories:

Publishing on the Web

Edit ./html/index.html as necessary. It should hopefully be fairly intuitive what needs changing in that file, and there are helpful comments as well. In theory, you should be able to copy (or symlink to) the ./html/ directory to your webroot and have working maps.