Currently, only scripts that import data into a PostGIS-enabled SQL-database.

As such, you need a running PostgreSQL database with PostGIS extensions.

Importing Shapefiles

Importing shapefiles is done using the tools brought by PostgreSQL:

shp2pgsql -s <SRID> -W <ENCODING> <SHAPEFILE> | psql -h <HOST> -d <DBNAME> -U <USERNAME>

Importing OpenStreetMap

We assume you have downloaded the area of your interest as a plain OSM XML file. Other formats are currently not supported.

In a first step, you have to write this data into a database. This is done using the script “osm2db.py”. Then, you probably want to build a road network from this data. This is done using the script “osmdb_buildWays.py”.

Importing OpenStreetMap into the database

The purpose of the osm2db.py tool is to store the contents of a given OSM XML file into a PostGIS-enabled PostgreSQL database.

The osm2db.py tool gets two parameter on the command line:

  • The definition of the database and the access to it that shall be used to store the data;
  • The OSM XML file to get the data from.

Consequently, the call is:

python osm2db.py <HOST>;<DB>;<SCHEMA>.<PREFIX>;<USER>;<PASSWD> <FILE>

Where:

  • <HOST>: the name of your database server
  • <DB>: the name of your database
  • <SCHEMA>: the database schema to store the database tables at
  • <PREFIX>: a prefix for the database tables
  • <USER>: the name of the user who has access (can generate tables and write into them) the database
  • <PASSWD>: the password of the user
  • <FILE>: the name of the OSM XML file that shall be imported.

The tool reads the OSM nodes, ways, and relations and stores them into generated database tables. The generated database tables are:

  • <PREFIX>_member: an OSM relation member (rid — relation id, elemid — the element id, type — the element's type as text, role — the element's role as text, idx — the element's index)
  • <PREFIX>_node: an OSM node (id, pos — the position in WGS84)
  • <PREFIX>_ntag: a node attribute (id, k — key as text, v — value as text)
  • <PREFIX>_rel: an OSM relation (id)
  • <PREFIX>_rtag: a relation attribute (id, k — key as text, v — value as text)
  • <PREFIX>_way: an OSM way (id, refs — list of geometry node ids)
  • <PREFIX>_wtag: a way attribute (id, k — key as text, v — value as text)

Building the road network from OpenStreetMap data

After inserting the data into the database using osm2db.py, you may extract/build the transport network using this data. This is done using the osmdb_buildWays.py script. It reads the imported OSM data and builds a database table that matches the road network representation used by UrMoAC. The generated database table is called “<PREFIX>_network”.

The call is:

python osmdb_buildWays.py <HOST>;<DB>;<SCHEMA>.<PREFIX>;<USER>;<PASSWD>

Where:

  • <HOST>: the name of your database server;
  • <DB>: the name of your database;
  • <SCHEMA>: the database schema to store the database tables at;
  • <PREFIX>: a prefix for the database tables;
  • <USER>: the name of the user who has access (can generate tables and write into them) the database;
  • <PASSWD>: the password of the user.

Using OpenStreetMap data to build tables of certain structures

The script osmdb_buildStructures.py builds a database table that can be used to read origins / destinations from by parsing the contents of an OSM representation imported using osm2db.py.

Some structures can be represented in different ways within OpenStreetMap. The script osmdb_buildStructures.py tries to offer a simple way to gather the information about all instances of specific structures and store them into a single table, independent to their original representation within OpenStreetMap.

For this purpose, osmdb_buildStructures.py reads a definition file that describes which nodes, ways, or relations, defined by their tags, belong to a specific kind of structures. This is done by reading a definitions file. The format of the definitions file is:

[<OSM_DATATYPE>]
<FILTER>
...
<FILTER>

The <OSM_DATATYPE> is one of “node”, “way”, and “relation”. After this data type definition, the filtering options are given that describe which elements of this data type shall be included. Each line describes a single set and the sets will be merged. A <FILTER> includes one or more key/value pairs. If more than one is given, they are divided by a ‘&’. An element needs to match all of the key/value pairs within a line for being included.

Some examples:

[node]
public_transport=stop_position

All OpenStreetMap nodes that have the combination key='public_transport' and value='stop_position' — all public transport stops — are included.

[node]
public_transport=stop_position&bus=yes

All OpenStreetMap nodes that have the combination key='public_transport' and value='stop_position' and the combination key='bus' and value='yes' — all public transport stops where busses stop — are included.

Currently, the following definition files are available:

osmdb_buildStructures.py is currently under development and experimental.

Importing GTFS

If accessibilities for using public transport shall be computed, UrMoAC requires the representation of the public transport offer within the region in form of GTFS data. GTFS data comes as text files. For using it with UrMoAC, it has to be imported into the database. The script importGTFS.py does this.

importGTFS.py is called like the other UrMoAC import scripts: python importGTFS.py <INPUT_PATH> <HOST>;<DB>;<SCHEMA>.<PREFIX>;<USER>;<PASSWD> Where:

  • <INPUTPATH>_: the path to the folder the GTFS files are located within;
  • <HOST>: the name of your database server;
  • <DB>: the name of your database;
  • <SCHEMA>: the database schema to store the database tables at;
  • <PREFIX>: a prefix for the database tables;
  • <USER>: the name of the user who has access (can generate tables and write into them) the database;
  • <PASSWD>: the password of the user.