/tiger-battlegrid

A reimplementation of the TIGER / OSM "Battlegrid" map using tile-reduce.

Primary LanguageJavaScriptMIT LicenseMIT

TIGER Battlegrid

A reimplementation of the now-defunct TIGER / OSM "Battlegrid" map using tile-reduce and OSM QA Tiles.

This project consumes TIGER roads vector tiles, the United States OpenStreetMap QA Tiles extract, and matches them. The resulting GeoJSON output represents segments that exist in TIGER but don't exist in OpenStreetMap. This output could be useful in finding areas of the map that haven't been mapped yet. It could also indicate TIGER data that is erroneous (because OSM has been more recently updated).

Refreshing the layer

Get fresh data

  1. Download the source data as a couple mbtiles files:

    mkdir -p /mnt/osmqa
    curl -L https://hot-qa-tiles.s3.amazonaws.com/latest.country/united_states_of_america.mbtiles.gz | gzip -dc > /mnt/osmqa/united_states_of_america.mbtiles
    curl -L https://s3.amazonaws.com/data.openstreetmap.us/tiger2023_expanded_roads.mbtiles > /mnt/osmqa/tiger2023_tiles.mbtiles
    

Install software

  1. Get the source code if you haven't already:

    cd /tmp
    curl -L https://github.com/iandees/tiger-battlegrid/archive/master.tar.gz | tar zxf -
    cd tiger-battlegrid-master/
    
  2. Install tippecanoe:

    sudo apt-get install -y build-essential libsqlite3-dev zlib1g-dev
    cd /tmp
    curl -L https://github.com/mapbox/tippecanoe/archive/1.34.3.tar.gz | tar zxf -
    cd tippecanoe-1.34.3/
    make -j$(nproc)
    sudo make install
    
  3. Install NVM, Node, and NPM:

    curl -L https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
    source ~/.profile
    nvm install 10
    nvm use 10
    
  4. Fix Ubuntu/npm/node-sqlite3 problems:

    npm install --global node-gyp@latest
    npm config set node_gyp $(npm prefix -g)/lib/node_modules/node-gyp/bin/node-gyp.js
    
  5. Install Node dependencies for tiger-battlegrid:

    cd /tmp/tiger-battlegrid-master/
    npm install
    

Create a new tileset

  1. Run the matching process and pipe it through Tippecanoe to generate an mbtiles dataset:

    mkdir /mnt/osmqa/tmp
    
    node index.js | \
    tippecanoe \
        --no-line-simplification \
        --buffer=0 \
        --read-parallel \
        --temporary-directory=/mnt/osmqa/tmp \
        --maximum-zoom=12 \
        -o /mnt/osmqa/missing_tiger.mbtiles
    

Upload the tileset to Mapbox

  1. Install Mapbox command line tools

    sudo apt-get install -y python3-pip
    pip3 install --user mapboxcli
    
  2. Create a new access token with all "uploads" permissions. Save the access token (you won't see it again) locally. Treat it like a password and don't share it with anyone.

  3. Store the access token for the Mapbox command line interface.

    export MAPBOX_ACCESS_TOKEN=<secret_token>
    
  4. Upload the tileset to Mapbox.

    ~/.local/bin/mapbox upload tiger2023-delta /mnt/osmqa/missing_tiger.mbtiles
    
  5. Upload the TIGER roads data to Mapbox as well.

    ~/.local/bin/mapbox upload tiger2023-roads /mnt/osmqa/tiger2023_tiles.mbtiles
    

Creating the new style on Mapbox

  1. In Mapbox Studio, click the New Style button, then click Upload Style and drop the style.json file from this repo on the upload area.