Paul’s Blog

A blog without a good name

Configuring MapProxy

MapProxy needs a couple of configuration files. One defines the layers, caches, and services that it runs. The other is used for “seeding” the cache, and specifies what to pre-render.

There’s a lot of documentation on MapProxy configuration files, and example ones can be created with mapproxy/bin/mapproxy-util create -t base-config.

The first file is mapproxy.yaml, which defines the layers to be rendered

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# This sets up the service at tiles/osm, which is useful for debugging.
# It doesn't get used for seeding.
services:
  demo:
  tms:
    use_grid_names: true
    origin: 'nw'

# Just one layer with OSM carto
layers:
  - name: osm
    title: OpenStreetMap Carto
    sources: [osm_cache]

caches:
  osm_cache:
    grids: [GLOBAL_WEBMERCATOR]
    sources: [osm-carto]
    meta_size: [8,8]
    cache:
      type: file
      # Force a meaningful name, since this is only being used for seeding
      directory: osm_tiles
      directory_layout: tms

sources:
  osm-carto:
    type: mapnik
    mapfile: openstreetmap-carto/project.xml

This file can be tested with the command mapproxy/bin/mapproxy-util serve-develop mapproxy.yaml, then the URL http://localhost:8080/tiles/1.0.0/osm/GLOBAL_WEBMERCATOR/0/0/0.png should be a single tile covering the world.

The second file is seed.yaml

1
2
3
4
5
seeds:
  world:
    caches: [osm_cache]
    levels:
      to: 8

This sets up a seeding area covering the entire world from zoom 0 to zoom 8. The seeding can be run with mapproxy/bin/mapproxy-seed -s seed.yaml -f mapproxy.yaml and the -c option can be added to set parallelism. After this is done, the tiles are generated, they just need to be packaged.