Note (18 January 2021)

We have updated the first part of these notes since the Baremaps source is now version 0.3.4, not 0.2.7 as indicated below, and there have been some changes in the way Baremaps is set up.

In summary, installing and running Baremaps is straightforward. For version 0.3.x with a reverse proxy to the Baremaps server on the usual Baremaps port (port 9000), in the case of an Apache2 server, the following must be added to /etc/apache2/ports.conf:

  • Listen 9000

and  a section needs to be added in /etc/apache2/apache2.conf for Baremaps tiles as follows:  

<Directory /tiles>

AllowOverride none

Require all granted

Header set Access-Control-Allow-Origin  "*">


Setting the header requires the Apache2 mod-headers module to be installed using:

  • sudo a2enmod headers

assuming that the module is listed in the /etc/apache2/mods-available.

Our reverse proxy points to local network address of the form The file /home/user/baremaps/openstreetmap-vecto/config.yaml must therefore be changed as follows:

  • host:

In focussing on OpenStreetMap technologies for use at the project level in various contexts - see summary - for planning, design, supervision, procurement, contracts, certification, project management, project supervision, contract administration, etc., we have yet to design and organise a suitable wiki site.  Regarding implementation details for the various core technologies, for the time being we shall use blog items. This item is for Baremaps OpenStreetMap vector tiles which are currently under development, but workable nonetheless - see


Baremaps provides an excellent way to serve vector tiles from an OpenStreetMap (OSM) database.

This is say, data is exported from a self-hosted OpenStreetMap "Rails Port" using Osmosis.

On Ubuntu18.04LTS, for user "user", I give terminal commands "as is" (i.e., with unedited paths).The Osmosis command to download from a local OSM Rails Port is:

/home/user/osm/osmosis/bin/osmosis --read-apidb-change host="localhost" database="openstreetmap" user="user" password="user" intervalBegin="2020-05-29_00:00:00" intervalEnd="2020-09-05_00:00:00" validateSchemaVersion="no" --write-xml-change file="/home/user/osm-site/sync_osm_databases/main-db-changes.xml"

It's probably wise to convert main-db-changes.xml to a pbf file (Osmium is recommended):

osmium cat main-db-changes.xml -o main-db-changes.pbf

Set up

To set up Baremaps, following Baremaps,  git clone from say a home directory (/home/user in my case):

  • $ cd
  • $ git clone

While in /home/user, set the PATH:

  • export PATH=$PATH:`pwd`/baremaps/bin
  • cd baremaps


  • wget


  • unzip
and copy the bin and lib folder in /home/user/baremaps/baremaps to /home/user/baremaps


It is best to first do a test with a small map following an old Baremaps example. that is updated. Currently, one only has a Docker image to fill a Postgis-extended Postgresql database (i.e., source files are not available). So run the following:

  • docker run --name baremaps --publish 5432:5432 -e POSTGRES_DB=baremaps -e POSTGRES_USER=baremaps -e POSTGRES_PASSWORD=baremaps -d baremaps/postgis:latest

One of course needs a Postgresql port (5432) to be available. So for example, shut down Postgresql if it  is running (sudo service postgresql stop) or kill any processes runing on port 5432 ("sudo netstat -tulpn ¦ grep LISTEN" followed by "sudo kill {pid}" where {pid] is the process id)

One can of course change the Postgresql port by using say 5433:5432 instead of 5432:5432 provided it is activated.

Check that the Baremaps Docker container is available:

  • docker container ls -a

and start:

  • docker start baremaps

The database needs to be prepared with the command:

  • baremaps execute  --database 'jdbc:postgresql://localhost:5432/baremaps?&user=baremaps&password=baremaps'   --file 'res://osm_create_extensions.sql'   --file 'res://osm_drop_tables.sql'  --file 'res://osm_create_tables.sql'  --file 'res://osm_create_gist_indexes.sql'  --file 'res://osm_create_gin_indexes.sql' 
A liechtenstein-latest.osm.pbf is available on the Baremaps github site as liechtenstein-latest.osm.pbf but also elsewhere (e.g., Geofabrik) and as a wget:

  • wget

The .osm file for Liechenstein is then imported into the Postgresql database with a terminal command. Baremaps now does the download itself, so the import command is:

  • baremaps  import --file '' --database 'jdbc:postgresql://localhost:5432/baremaps?allowMultiQueries=true&user=baremaps&password=baremaps'

which after some warnings ends with "ImportTask - Importing data".

Form the old Baremaps OpenStreetMap example, copy/download config.yaml to /home/user/baremaps.

The command:

  • baremaps serve --database 'jdbc:postgresql://localhost:5432/baremaps?user=baremaps&password=baremaps' --config 'config.yaml' --watch-changes

starts a tile server at http://localhost:9000 showing what is called a Mapbox blueprint style three-dimensional map of Liechtenstein.


To display the OSM database tiles, while in /home/user/baremaps git clone openstreetmap-vecto from github:

  • git clone

and then move to the directory (/home/user/baremaps/openstreetmap-vecto):

  • cd openstreetmap-vecto

To ensure that cached images are not used, the suggestion at this stage is to make sure that you have no Docker images and containers present on your system. You may need to stop the test:

  • docker stop baremaps
  • docker stop postgis
  • docker container rm baremaps
  • docker container rm postgis

and then maybe purge your system:

  •  docker system prune
to make sure that baremaps/postgis is not running.

Edit web page

Before setting up the OSM tiles you may want to add some controls and the like to the map (Baremaps currently only includes a navigation control, while the homepage displays no controls).

A relatively simply way is to edit the resources file that is used by the Baremaps java application.

In /home/user/baremaps/baremaps-server/src/main/resources there is index.ftl. Edit this Mapbox file by perhaps changing the title, adding controls, etc.:

  • map.addControl(new mapboxgl.NavigationControl());
For adding a marker:

  var popup = new mapboxgl.Popup({ offset: 25 })

   .setText('Marais Rouge parking');

var marker = new mapboxgl.Marker()

   .setLngLat([6.157468, 46.484028])



The Mapbox  examples  indicate what is possible.

Personally, I also prefer to host the Mapbox files on my own servers. So for a standard Apache2 web server set-up I download mapbox-gl.css and mapbox-gl.js, copy them to /var/www/html/baremaps and edit index.ftl as follows:

<link href='' rel='stylesheet'/>

<script src=''></script>

The files are downloaded using for example the links given in index.ftl:

  • wget
  • wget

In order to incorporate the edited index.ftl file it is necessary to compile the Baremaps Java application. Using Maven is perhaps the simplest. So in /home/user/baremaps, with tests skipped:

  • mvn clean package -DskipTests



There is one complication. A relatively well-known byte error may be thrown during execution if the Java version used to compile Baremaps is not the same as that used by the Baremaps developers. 

The simplest solution is to run the Maven package with the same version as the Java version of the jar files in (which was downloaded at the begining). The jar files in are currently version 0.2.6 (i.e., the cli jar file in /home/user/baremaps/ is called baremaps-cli-0.2.6.jar). The Java version of baremaps-cli is currently 0.2.7. 

It is necessary to change the version of baremaps-cli to 0.2.6 by running:

  •  cd /home/user/baremaps
  • mvn versions:set -DnewVersion=0.2.6

Then run:

  • mvn clean package

and copy/paste baremaps-cli-0.2.6.jar in /home/user/baremaps/baremaps-cli/target/ to the /baremaps/bin directory in the that is also in /home/user/baremaps/baremaps-cli/target/

The file with the edited baremaps-cli jar file is then copied to /var/www/html/baremaps.

This procedure possibly assume that baremaps-cli does not change when other basemaps jars are changed to new versions. This seems to be the case at present.

Build -

Before building, one needs to edit the Dockerfile in /home/user/baremaps/openstreetmap-carto by changing: 

  • RUN wget 

to the at the website:

  • RUN wget  

As explained on the  Baremaps openstreemap-vecto github page, the Docker image for osmvecto can be built using: 

  • docker build . --tag baremaps/osmvecto

Personally, I have a Docker account called something like "peter". One may need to remove docker images, so list them:

  • docker images

 and remove the image using a name or an id:

  • docker rmi peter/osmvecto
or maybe:
  • docker rmi peter/osmvecto:latest

Then I would use:

  • cd /home/user/baremaps/openstreetmap-vecto
  • docker build . --tag peter/osmvecto 

and push the Docker image after it is built to Docker using:

  • docker push peter/osmvecto
Build - script

The build command calls a script (scripts/ In order to display the database data, needed to be edited by changing: 

  • wget -O openstreetmap.pbf


  • wget -O openstreetmap.pbf

where my-databse.osm.pdf is something like my-main-database-changes.osm.pbf or  switzerland-padded-8jun20-clipped_600_650_4635_4675.osm.pbf that is stored in the apache2 website's baremaps directory. 

Build and serve


  • docker build . --tag peter/osmvecto 

is run and the image maybe pushed to Docker, the image is run (from a terminal at /home/user/baremaps/openstreetmap-vecto) using the command:

  • docker run -d --name osmvecto --publish 5432:5432 --publish 9000:9000 --volume $(pwd):/home peter/osmvecto:latest

It is probably wise to restart the postgresql database:

  • sudo service postgresql restart

and the data is imported into the database:

  • docker exec -ti osmvecto bash -c scripts/

and the Baremaps tile server is started with:

  • docker exec -ti osmvecto bash -c scripts/


The config.yaml file in /home/user/baremaps/openstreetmap-carto and the individual sylesheet and config yaml files in  /home/user/baremaps/openstreetmap-carto/config in can be altered while the server is live. For config.yaml, I change the host and keep the port:

  • host:
  • port: 9000

and reverse-proxy to this from an nginx website with a CORS header added (see above).

The stylesheets are in development. Up to version 0.3.0, an interesting official suggestion was to add the following to the building layer file (/home/user/baremaps/openstreetmap-vecto/config/building/layer.yml)

  - minZoom: 14

    maxZoom: 18


      SELECT id, tags, geom 

      FROM osm_nodes WHERE tags ? 'building'

  - minZoom: 14

    maxZoom: 18


      SELECT id, tags || hstore('building:height'::text, ((CASE WHEN tags -> 'building:levels' ~ '^[0-9\.]+$' 

      THEN tags -> 'building:levels' 

      ELSE '1' END)::real * 3)::text), geom 

      FROM osm_ways 

      WHERE tags ? 'building' 

A building-extrusion style is then added to the building stylesheet.yaml. This gives extruded three-dimensional buildings based on the building level as explained in the old Baremaps building example.

This extrusion still works in version 0.3.x (add the style and for the config.yaml, add from the second -minZoom: 14 expression since in Baremaps 0.3.x  the sql query is for  osm_relations, not osm_nodes. The extrusion is not perfect (e.g., roads pass through buildings) but it's a start.



One suspects that it should be possible to update the Docker image directly and not rebuild the image each time index.ftl is changed. For example, following the command:

  • docker run -it peter/osmvecto:latest /bin/bash

the command: 

  • find / -type f -iname "*baremaps*"

lists the baremaps jar files.

baremaps-cli-0.2.6.jar is removed with:

  • rm /lib/baremaps-cli-0.2.6.jar

and the new baremaps-cli-0.2.6.jar discussed above can be copied into the image with:

  • sudo docker baremaps-cli-0.2.6.jar abcdef123456:/lib 

after submitting "exit" to exit the docker container. One understands that the id of the parent Docker layer is abcdef123456 which is displayed at the command prompt on running the bin/bash/ command. 

This approach needs checking as locally built Docker images are relatively complicated.


Take care to run the, and terminal commands from /home/user/baremaps/openstreemap-vecto otherwise the bash command will not work (a fairly well known issue). Also, if any of the bash files are changed it is necessary to stop and remove the osmvecto Docker container, and restart:

  • docker containetr stop osmvecto
  • docker container rm osm vecto
  • docker run -d --name osmvecto --publish 5432:5432 --publish 9000:9000 --volume $(pwd):/home peter/osmvecto:latest


There is of course much to be done in terms of completing the layers and style sheets. But overall the results so far are excellent since a fairly complicated pipeline can be set up and adjusted to a limited extent to give workable, OSM vector tiles, not only at a localised project level but also at a much larger, even global, scale.

NOTE: as noted earlier, the discussion above about openstreetmap-vector relates to version 0.2.6. With version 0.3.x, a server is built directly. This blog will be updated accordingly 

24 December 2020

Phone: +41792989666
Skype: live:petergboswell
WhatsApp: PeterBoswellcom
Messenger: petergboswell
Telegram: PeterBoswellBot