Sequentially-generate-planet-mbtiles

From OpenStreetMap Wiki
Jump to navigation Jump to search
sequentially-generate-planet-mbtiles
Author: lambdajack/sequentially-generate-planet-mbtiles/graphs/contributors
License: MIT License
Platforms: Linux, macOS, and Windows
Version: 2.2.0
Language: English
Source code: lambdajack/sequentially-generate-planet-mbtiles
Programming language: Go

Generate planet-scale vector tilesets on low memory / low cpu count devices

Sequentially-generate-planet-mbtiles creates vector tiles (in OpenMapTiles format) from a the latest planet.osm.pbf file downloaded from the OpenStreetMap. The programme is a single binary which will run on linux/macOS/Windows.

In short, the programme will:

1. Download the latest planet.osm.pbf file from source.

2. Segregate the data into slices manageable with low ram requirements.

3. Generate mbtiles from the slices (with help from tilemaker - no need to install separately)

4. Merge the mbtiles file into a single, properly merged planet.mbtiles file (with help from tippecanoe - no need to install separately)

Sequentially-generate-planet-mbtiles is designed to be an easy solution for people who are not looking for extremely deep customisation (although config files can be provided to do such), but who want quick and pretty tilesets with little to no effort on their part. Simply clone the repository and run the binary.

The only requirement is that Docker is installed as the binary will generate containers to complete the work.

As of release v2.2.0 - to generate your tiles:

1. Have Docker installed

2. git clone --recurse-submodules https://github.com/lambdajack/sequentially-generate-planet-mbtiles

3. ./release/v2.2.0-sequentially-generate-planet-mbtiles.exe (you may need to run with sudo privileges depending on your docker installation)

Source code: https://github.com/lambdajack/sequentially-generate-planet-mbtiles

From the README:

README (github)

Why?

There are some wonderful options out there for generating and serving your own map data and there are many reasons to want to do so. My reason, and the inspiration for this programme was cost. It is expensive to use a paid tile server option after less users using it than you might think. The problem is, when trying to host your own, a lot of research has shown me that almost all solutions for self generating tiles for a map server require hugely expensive hardware to even complete (it's not uncommon to see requirements for 64 cores and 128gb RAM!). Indeed the largest I've seen wanted 150gb of the stuff!. For generating the planet that is. If you want a small section of the world, then it is much easier. But I need the planet - so what to do? Generate smaller sections of the world, then combine them.

That's where sequentially-generate-planet-mbtiles comes in. It downloads the latest osm data, splits it into manageable chunks, generates mbtiles from those chunks and then stitches it all together.

This programme aims to be a simple set and forget, one liner which gives anyone - a way to get a full-featured and bang up to date set of vector tiles for the entire planet on small hardware.

It's also designed (work in progress) to be fail safe - meaning that if your hardware (or our software) does crash mid process, you have not lost all your data, and you are able to start again from a point mid-way through.

This also uses the openmaptiles spec, meaning that when accessing the served tiles you can easily use most of the open source styles available. The default is aimed at using the OSM Bright style. More information on styles can be found below.

Considerations

Hardware usage - this will consume effectively 100% CPU for up to a few days and will also do millions of read/writes from ssd/RAM/CPUcache. While modern hardware and vps' are perfectly capable of handling this, if you are using old hardware, beware that its remaining lifespan may be significantly reduced.

Cost - related to the above, while this programme and everything it uses is entirely free and open source - the person's/company's computer you're running it on might charge you electricity/load costs etc. Please check with your provider, how they handle fair use.

Time - your hardware will be unable to do anything much other than run this programme while it is running. This is in order to be efficient and is by design. If your hardware is hosting other production software or will be needed for other things in the next few days, be aware that it will perform suboptimally while this is running.

Bandwidth - this will download the entire planet's worth of openstreetmap data directly from OSM. At the time of writing, this is approx. 64GB. **Please note: ** the programme will look for a planet-latest.osm.pbf file in the data/pbf folder. If this is already present, it will skip the download and use this file. If you already have the data you wish to generate mbtiles for, you can place it there to skip the download. This can be useful if you want historical data, or are generating the mbtiles on multiple computers.

Data generation - in order to remain relatively fast on low spec hardware, this programme systematically breaks up the OSM data into more manegable chunks before processing. Therefore, expect around 300GB of storage to be used up on completion.

Requirements

About 300GB clear disk space for the entire planet. Probably an SSD unless you like pain, suffering and the watching the slow creep of old age.

About 4gb of clear RAM (so maybe 6gb if used on a desktop pc). We are working on options in the future for lower RAM requirements.

Time. As above, this has been written to massively streamline the process of getting a planetary vector tile set for the average person who might not have the strongest hardware or the desire to spend £££ on a 64 core 128gb RAM server. Unfortunately, if you cut out the cost, you increase the time. Expect the process to take a couple of days from start to finish on average hardware.

FAQ

How long will this take? Low spec hardware? Whole planet? A few days. Maybe less than 48 hours for 16 CPUs.

Would I use this if I have powerful hardware? Maybe. Since the programme essentially saves its progress as it goes, even if you have strong hardware, you are reducing the time taken to redo the process in the event of a crash or file corruption. Further, the RAM is what is really saved here so if you have say 32 cores and 64gb RAM, you still would not be able to generate the entire planet by loading it into memory. Additionally, it just saves time configuring everything.

Why do I have to run part of the programme with 'sudo' privileges? Many docker installations require sudo to be executed. You may not have to execute the programme with sudo.

Do I have to download the entire planet? At present, yes. Since if you are not downloading the entire planet, there are other tools out there which do a fine job of getting you mbtiles. We are working on being able to generate mbtiles for smaller areas (such as continents which may still not fit into the average computers RAM)

Does 'low spec' mean I can run it on my toaster? Maybe, but mostly not. But you can happily run it on you 4core CPU/4gb RAM home pc without too much trouble. Just time.

Didn't this used to use GeoFabrik? It did but the plan was always to move away from geofabrik sources for the planet since it felt unnecessary, when the data was already available direct from source. Further, the GeoFabrik data leaves gaps in the ocean and some of their slices require more than 4gb RAM to process in memory. Ultimately, by getting the data from source, we have more control over it.

Why would I use this over Planetiler? Planetiler is a fantastic project, however it still requires minimum 32gb RAM to complete the entire planet (0.5x the size of the planet pbf file).

The awesome vector tiles page lists other vector tile clients and generators.