Skip to main content

Download map tiles and store them in an MBTiles database

Project description

download-tiles

PyPI Changelog Tests License

Download map tiles and store them in an MBTiles database

Installation

Install this tool using pip:

$ pip install download-tiles

Usage

This tool downloads tiles from a specified TMS (Tile Map Server) server for a specified bounding box and range of zoom levels and stores those tiles in a MBTiles SQLite database. It is a command-line wrapper around the Landez Python libary.

Please use this tool responsibly. Consult the usage policies of the tile servers you are interacting with, for example the OpenStreetMap Tile Usage Policy.

Running the following will download zoom levels 0-3 of OpenStreetMap, 85 tiles total, and store them in a SQLite database called world.mbtiles:

download-tiles world.mbtiles

You can customize which tile and zoom levels are downloaded using command options:

--zoom-levels or -z

The different zoom levels to download. Specify a single number, e.g. 15, or a range of numbers e.g. 0-4. Be careful with this setting as you can easily go over the limits requested by the underlying tile server.

--bbox or -b

The bounding box to fetch. Should be specified as min-lon,min-lat,max-lon,max-lat. You can use bboxfinder.com to find these for different areas.

--city or --country

These options can be used instead of --bbox. The city or country specified will be looked up using the Nominatum API and used to derive a bounding box.

--show-bbox

Use these to output the bounding box that was retrieved for the --city or --country without retrieving any tiles.

--attribution

Attribution string to bake into the metadata table. This will default to © OpenStreetMap contributors unless you use --tiles-url to specify an alternative tile server, in which case you should specify a custom attribution string.

--tiles-url

The tile server URL to use. This should include {z} and {x} and {y} specifiers, and can optionally include {s} for subdomains.

The default URL used here is for OpenStreetMap, http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png

--tiles-subdomains

A comma-separated list of subdomains to use for the {s} parameter.

--verbose

Use this option to turn on verbose logging.

--cache-dir

Provide a directory to cache downloaded tiles between runs. This can be useful if you are worried you might not have used the correct options for the bounding box or zoom levels.

Development

To contribute to this tool, first checkout the code. Then create a new virtual environment:

cd download-tiles
python -mvenv venv
source venv/bin/activate

Or if you are using pipenv:

pipenv shell

Now install the dependencies and tests:

pip install -e '.[test]'

To run the tests:

pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

download-tiles-0.3.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

download_tiles-0.3-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file download-tiles-0.3.tar.gz.

File metadata

  • Download URL: download-tiles-0.3.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for download-tiles-0.3.tar.gz
Algorithm Hash digest
SHA256 19ec29f9638c51b75834fd5885991ef5f20aba55ed0dd49b14e1bca8487311a9
MD5 31084db7f0795cff7667f79653a26771
BLAKE2b-256 479f728eb7f6dcb5fa484e1714d9491161466c2d4f8da9534e5e747bdc880c72

See more details on using hashes here.

File details

Details for the file download_tiles-0.3-py3-none-any.whl.

File metadata

  • Download URL: download_tiles-0.3-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for download_tiles-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 57ac24383a24b9c47afdea9e69911ccfe3a11026eee59122fcd6199680bcb207
MD5 2bf37d99a1b72ae594104abd92ac4323
BLAKE2b-256 c07e948be6db97809ef04e427ab08827192fec5e9302e09074efebbf8932e2d4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page