Difference between revisions of "Marble/OSMVectorTileCreation"

Jump to: navigation, search
(Created page with "= OSM Vector Tiles = == Creating tiles from a pbf file == As an example we'd like to render tiles for tile level 13, 15 and 17 of San Francisco. First you need the osm.pbf ...")
 
(Running the VectorTileCreator)
Line 51: Line 51:
 
-z 13 15.
 
-z 13 15.
  
for example to exclude level 17 (which takes looong for large regions) once called, the script does the following
+
This would allow to exclude e.g. level 17 (which can take between < 1 sec for small tiles but > 10 secs for large tiles depending on the input size). Once called, the script does the following
 
* It parses the region file to read which file to work on and which boundaries it has
 
* It parses the region file to read which file to work on and which boundaries it has
 
* To speed things up, it then creates another file with only the given boundaries inside (e.g. if you pass california-latest.osm.pbf and work on san francisco it will create a temporary file that has only san francisco inside)
 
* To speed things up, it then creates another file with only the given boundaries inside (e.g. if you pass california-latest.osm.pbf and work on san francisco it will create a temporary file that has only san francisco inside)

Revision as of 11:59, 18 October 2015

OSM Vector Tiles

Creating tiles from a pbf file

As an example we'd like to render tiles for tile level 13, 15 and 17 of San Francisco. First you need the osm.pbf file for that region. In our case we download that from:

http://download.geofabrik.de/north-america/us/california.html

or to be more specifically: http://download.geofabrik.de/north-america/us/california-latest.osm.pbf

Creating the tools - osmconvert and osmfilter

Now we need the tools for conversion and filtering the pbf file into tiles. In order to compile the tools you should have zlib installed on your system (e.g. via sudo apt-get install zlib1g-dev). Then run:

cd /tmp
wget http://m.m.i24.cc/osmconvert.c
gcc -O3 -o osmconvert osmconvert.c -lz
sudo mv osmconvert /usr/local/bin
and pretty much the same for osmfilter
wget http://m.m.i24.cc/osmfilter.c
gcc -O3 -o osmfilter osmfilter.c
sudo mv osmfilter /usr/local/bin

if that works, running

osmconvert -h

and also

osmfilter -h

should output usage instructions.

Running the VectorTileCreator

Now our tool is needed. You need python version 2 or 3 to be installed. In a shell, go to the marble sources directory and then

cd tools/vectortilecreator

now running

./vectortilecreator.py -h

should give usage instructions.

The tile cutter tool works as follows: You call it with a region file as parameter (or several). It will generate tiles in the currenty directory unless you use the -d option: For example -d ~/.local/share/marble/maps/earth/vectorosm is what you want for local tiles. By default it will generate tiles for zoom levels 13, 15, 17. You can overwrite that using the -z switch -z 13 15.

This would allow to exclude e.g. level 17 (which can take between < 1 sec for small tiles but > 10 secs for large tiles depending on the input size). Once called, the script does the following

  • It parses the region file to read which file to work on and which boundaries it has
  • To speed things up, it then creates another file with only the given boundaries inside (e.g. if you pass california-latest.osm.pbf and work on san francisco it will create a temporary file that has only san francisco inside)
  • Afterwards it iterates over the zoom levels passed. For each level it calculates the tiles that are inside the boundaries.

Then it calls osmconvert for each tile to generate the tile

  • If it also finds a file levels/$ZOOM.level it will call osmfilter afterwards
  • And finally the result is zipped

Content is available under Creative Commons License SA 4.0 unless otherwise noted.