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.

As an alternative to the official guide below, there is an article on the Flightgear wiki for osm2city on Windows maintained by a user.



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.8 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)
  • Pillow
  • pyproj
  • requests
  • scipy
  • shapely
  • psycopg2-binary

Please make sure to use Python 3.8+ 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/pingu/bin/virtualenvs/o2c38
user$ source /home/pingu/bin/virtualenvs/o2c38/bin/activate
(o2c38) user$ cd /home/pingu/osm2city

(o2c38) user$ pip install --upgrade pip
(o2c38) user$ pip install --upgrade setuptools

(o2c36) user$ pip install -r requirements.txt

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 20.04 the following packages have amongst others been installed (not exhaustive list):

  • postgresql-12
  • postgis
  • postgresql-12-postgis-3
  • postgresql-client-12
  • postgresql-common
  • pgadmin3
  • python3-psycopg2

Installing on Windows

For windows, the best way to get PostgreSQL and PostGI is to use this download page: version 9.6 was tested and works well on Windows. After installation of PostgreSQL, use the Stackbuilder tool included with PostgreSQL to download and install PostGIS version 2.5, which is found under “spatial extensions”.

Creating a database and loading data

Create a database user:

$ sudo -u postgres psql
postgres=# CREATE USER gisuser WITH PASSWORD 'myPassword';
postgres=# \q
  • 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
sudo -u postgres psql
postgres=# \connect kbos
kbos=# CREATE EXTENSION postgis;
kbos=# CREATE EXTENSION hstore;
kbos=# GRANT ALL PRIVILEGES ON DATABASE kbos to gisuser;
kbos=# \q

psql --username=gisuser -d kbos -f /home/pingu/bin/osmosis-latest/script/pgsnapshot_schema_0.6.sql
psql --username=gisuser -d kbos -f /home/pingu/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. However, this can take a long time and actually not even be worth it, even though you might use the database many times:

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.


You might 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.


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