Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jqtrde/8812769 to your computer and use it in GitHub Desktop.
Save jqtrde/8812769 to your computer and use it in GitHub Desktop.
#!/bin/bash
# This script is for exporting MBTiles directly to your Mapbox account.
# Requires a Mapbox account with sufficient storage for your tiles and
# authorized with your TileMill 0.10.0 install.
# Note that the maximum file transfer size is 5GB.
# Adapted from https://gist.github.com/springmeyer/7875415.
# Settings: edit these as needed
PROJECT_NAME="geography-class" # the folder name in your /project directory
OUTPUT_DIRECTORY="~/Documents/MapBox/export/"
# first change into TileMill code directory
cd /Applications/TileMill.app/Contents/Resources/
# export options https://www.mapbox.com/tilemill/docs/manual/exporting/#command_line_export_options
# --format=[format] Export format (png|jpeg|tiff|pdf|svg|mbtiles|upload|sync). (Default: undefined)
# --bbox=[xmin,ymin,xmax,ymax] Comma separated coordinates of bounding box to export. (Default: undefined)
# --minzoom=[zoom] MBTiles: minimum zoom level to export. (Default: undefined)
# --maxzoom=[zoom] MBTiles: maximum zoom level to export. (Default: undefined)
# --width=[width] Image: image width in pixels. (Default: 400)
# --height=[height] Image: image height in pixels. (Default: 400)
# --url=[url] URL to PUT updates to. (Default: undefined)
# --log Write crash logs to destination directory. (Default: undefined)
# --quiet Suppresses progress output. (Default: undefined)
# --scheme=[scanline|pyramid|file] Enumeration scheme that defines the order in which tiles will be rendered. (Default: "scanline")
# --job=[file] Store state in this file. If it exists, that job will be resumed. (Default: false)
# --list=[file] Provide a list file for filescheme render. (Default: false)
# --metatile=[num] Metatile size. (Default: undefined)
# --scale=[num] Scale factor (Default: undefined)
# --concurrency=[num] Number of exports that can be run concurrently. (Default: 4)
# --files=[path] Path to files directory. (Default: "/home/aj/Documents/MapBox")
# --syncAPI=[URL] MapBox API URL. (Default: "http://api.tiles.mapbox.com")
# --syncURL=[URL] MapBox sync URL. (Default: "https://tiles.mapbox.com")
# --syncAccount=[account] MapBox account name. (Default: "")
# --syncAccessToken=[token] MapBox access token. (Default: ""). Obtain from ~/.tilemill/config.json
# --verbose=on|off verbose logging (Default: "on")
# --config=[path] Path to JSON configuration file.
# the export
# hint: use http://bboxfinder.com/ to get bounds in lon/lat
BOUNDS="-125.090332,45.336702,-116.147461,49.253465"
NAME="my-new-tiles"
ACCOUNT="username"
TOKEN="example1234"
FORMAT="upload"
echo "Exporting $NAME using $BOUNDS to ${OUTPUT_DIRECTORY}/${NAME}.mbtiles"
./index.js export ${PROJECT_NAME} ${OUTPUT_DIRECTORY}/${NAME}.mbtiles --minzoom=0 --maxzoom=1 --bbox=${BOUNDS} --format={FORMAT} --syncAccount={ACCOUNT} --syncAccessToken={TOKEN}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment