Running a Tile Server Questions

Good morning,

I am following this guide: Manually building a tile server (Ubuntu 24.04) – Switch2OSM and trying to build my own tile server.

I have two questions/confirmations:

  1. Do I need to download and pre-load data? What happens if someone asks a tile belonging to a dataset I did not import?
  2. Say I only want to load zoom 5-12. Can I download only those datasets of the whole world? (according to this OSM - Tile Calculator this should limit pretty heavily my disk-space requirements). If this is possible how can I do this? Looking at the tiles repositories I only see files for everything.

Thanks a lot!

they will get empty tile (like in unmapped area), entirely filled with land/water/whatever background is used by given map style

Do you mean that you want to download filtered data without details such as shops that will not be displayed at this zoom levels?

Note that you download data, not already generated tiles. Generated tiles take much more space than downloaded data if you generate many zoom levels.

Entire Germany is 4.2 GB of OSM data, see Geofabrik Download Server

Thank you very much for your reply.

My previous message was misleading in its wording for point 2. I think I get the gist of it after your reply.

So say I want to serve tiles for “the whole world” between zoom 5-12.
I should download the whole world (e.g. these 8 files listed on the homepage of this site: https://download.geofabrik.de/).

Then, can I “import/generate” only the tiles for zooms I need (5-12) and then potentially trash the initial 8 downloaded files?

Looking at the guide I am trying to follow I suspect this command might then be modified to import only the levels I need?

sudo -u _renderd osm2pgsql -d gis --create --slim  -G --hstore --tag-transform-script ~/src/openstreetmap-carto/openstreetmap-carto.lua -C 2500 --number-processes 1 -S ~/src/openstreetmap-carto/openstreetmap-carto.style ~/data/azerbaijan-latest.osm.pbf

Or probably I need to set min-max in the /etc/renderd.conf file?

Thanks a lot again!

That’s about it, but you’ll be better off starting with a small extract, say Liechtenstein to get experience on small hardware.
Then you will probably want to filter out unnecessary data (that shows only beyond z12) with Osm2pgsql, then import the complete planet you finf at planet.openstreetmap.org

Thank you yvecai!

This file seems just what I needed: https://planet.openstreetmap.org/pbf/planet-latest.osm.pbf

Do you know how to import only needed levels using _renderd/osm2pgsql instead of importing everything and then remove/filter? My disk-space won’t be enough for the operation so I am looking for a command to avoid the extra step.

Thanks a lot!

That would be done by Osm2pgsql. This goes beyond switch2osm, but the Osm2pgsql software documentation is really good.