Installation [Builder]

The following specifies software and data requirements as part of the installation. Please be aware that different steps in scenery generation (e.g. generating elevation data, generating scenery objects) might require a lot of memory and are CPU intensive. Either use decent hardware or experiment with the size of the sceneries. However it is more probable that your computer gets at limits when flying around in FlightGear with sceneries using osm2city than when generating the sceneries.



osm2city is written in Python and needs Python for execution. Python is available on all major desktop operating systems — including but not limited to Windows, Linux and Mac OS X. See

Currently Python version 3.5 is used for development and is therefore the recommended version.

Python Extension Packages

osm2city uses the following Python extension packages, which must be installed on your system and be included in your PYTHONPATH:

  • descartes
  • matplotlib
  • networkx
  • numpy (on Windows you need Numpy+MKL)
  • pil (Pillow)
  • scipy
  • shapely
  • psycopg2-binary
  • psycopg2cffi (this and the next one are only needed when using PyPy (see below)
  • psycopg2cffi-compat

Please make sure to use Python 3.5+ compatible extensions. Often Python 3 compatible packages have a “3” in their name. Most Linux distributions come by default with the necessary packages — often they are prefixed with python- (e.g. python-numpy). On Windows WinPython ( together with Christoph Gohlke’s unofficial Windows binaries for Python extension packages ( works well.

Virtual Environments

The following is optional respectively a better way to install Python extension packages then what was described above — however it might be a bit more difficult.

You might want to consider using a Python Virtualenv instead of using Python directly as installed in your OS. Once you have installed virtualenv on your system, you should create a base directory for your virtual environments (e.g. $HOME/bin/virtualenvs).


user$ python3 -m venv /home/vanosten/bin/virtualenvs/o2c36
user$ source /home/vanosten/bin/virtualenvs/o2c36/bin/activate
(o2c36) user$ pip install matplotlib
(o2c36) user$ pip install networkx
(o2c36) user$ pip freeze

PyPy as an Alternative Python Interpreter

NB: Experiments in Spring 2018 with Python 3.6 on Linux and PyPy3.6 version 6.0 showed that PyPy does not improve speed, actually it decreases run-time in osm2city.

PyPy is a fast, compliant alternative implementation of Python. Thanks to its Just-in-Time compiler, Python programs often run faster on PyPy. You download it from its website. In many cases you need to choose the portable version on Linux. Once this is done, create a virtual environment, activate it and install the extensions using pip like in the previous chapter (for scipy you might need to install gfortran into your OS before).

user$ /home/vanosten/bin/pypy3.5-6.0.0-linux_x86_64-portable/bin/virtualenv-pypy /home/vanosten/bin/virtualenvs/o2cpypy3560
user$ source /home/vanosten/bin/virtualenvs/o2cpypy3560/bin/activate
(o2cpypy3560) user$ pip install matplotlib

Installation of osm2city

There is no installer package - neither on Windows nor Linux. osm2city consists of a set of Python programs and the related data in “osm2city-data”. You need both.

Do the following:

  1. Download the packages either using Git or as a zip-package.
  2. Add the osm2city directory to your PYTHONPATH (see below).
  3. Make sure that you have set $FG_ROOT.


You can read more about this at

On Linux you would typically add something like the following to your .bashrc file:


Setting Operating System Environment Variable $FG_ROOT

The environment variable $FG_ROOT must be set in your operating system or at least your current session, such that fgelev can work optimally. How you set environment variables is depending on your operating system and not described here. I.e. this is NOT something you set as a parameter in params.ini!

You might have to restart Windows to be able to read the environment variable that you set through the control panel. In Linux you might have to create a new console session.

$FG_ROOT is typically a path ending with directories data or fgdata (e.g. on Linux it could be /home/pingu/bin/fgfs_git/next/install/flightgear/fgdata; on Windows it might be C:\flightGear\2017.3.1\data).

BTW: you have to set the name of the variable in your operating system to FG_ROOT (not $FG_ROOT).

Setting up PostGIS

Installed Packages on Linux

On Ubuntu 17.10 the following packages have amongst others been installed (not exhaustive list):

  • postgresql-9.6
  • postgresql-9.6-postgis-2.3
  • postgresql-client-9.6
  • postgresql-contrib-9.6
  • pgadmin3
  • postgis
  • python3-psycopg2

On top of that you also need a 0.6+ version of Osmosis. Please be aware of the fact that you also need a related version of Java and that e.g. in Ubuntu 17.10 Osmosis is out of date — i.e. you should NOT use a (Linux) distribution package and instead use the one from the source.

Creating a database and loading data

  • The following examples of usage will assume that the database name is kbos and the user is gisuser. Of course your installation can differ and you can set different parameters foŕ Database.
  • See Getting OpenStreetMap Data. To get data for the whole planet go to Planet OSM (
  • Setting up a PostGIS database as described in PostGIS setup (replace pgsnapshot with whatever you named the database, e.g. osmogis). For now schema support for linestrings does not have to be set up. However you need to run at least pgsnapshot_schema_0.6.sql and pgsimple_schema_0.6_bbox.sql.
  • Load data (see also PostGIS Tasks (Snapshot Schema))
  • Update the indices in the database

Preparing the database might look as follows:

$ sudo -u postgres createdb --encoding=UTF8 --owner=gisuser kbos

$ psql --username=postgres --dbname=kbos -c "CREATE EXTENSION postgis;"
$ psql --username=postgres --dbname=kbos -c "CREATE EXTENSION hstore;"'

$ psql --username=postgres -d kbos -f /home/vanosten/bin/osmosis-latest/script/pgsnapshot_schema_0.6.sql
$ psql --username=postgres -d kbos -f /home/vanosten/bin/osmosis-latest/script/pgsnapshot_schema_0.6_bbox.sql

The you might first cut down the downloaded OSM pbf-file to the needed area and finally import it to the database:

$ /home/vanosten/bin/osmosis-latest/bin/osmosis --read-pbf file="/media/sf_fg_customscenery/projects/TEST/massachusetts-latest.osm.pbf" --bounding-box completeWays=yes top=42.625 left=-72 bottom=42.125 right=-70.5 --write-pbf file="/media/sf_fg_customscenery/projects/TEST/kbos.pbf"

$ /home/vanosten/bin/osmosis-latest/bin/osmosis --read-pbf file="/media/sf_fg_customscenery/projects/TEST/kbos.pbf" --log-progress --write-pgsql database=kbos host=localhost:5433 user=gisuser password=!Password1

And finally you might want to index the tags in hstore to get some more query speed after loading the data (on a medium powered machine for the relatively small KBOS area this takes ca. 30 minutes):

CREATE INDEX idx_nodes_tags ON nodes USING gist(tags);
CREATE INDEX idx_ways_tags ON ways USING gist(tags);
CREATE INDEX idx_relations_tags ON relations USING gist(tags);


  • I have not found out how to add an additional region to an already populated database. Therefore you might need to run /home/pingu/bin/osmosis-latest/bin/osmosis --truncate-pgsql database=kbos before getting a new region into the database if you have only one database. The better approach is of course using several databases in parallel.

Other Tools

You might want to check out Sławek Mikuła’s scripts for osm2city parsing and generation, which make some of the repetitive manual tasks involved in generating a scenery a bit easier.


JOSM is an offline editor for OSM-data. It is not strictly required for pre- or post-processing of osm2city, but it might be handy for debugging and detailed investigations.

Information about JOSM including installation instructions can be found at