Skip to content

Run NetAScore manually with Python

Christian Werner edited this page Dec 4, 2024 · 5 revisions

This sections describes how to run the project directly on your machine without Docker. For information on how to run it in a Docker environment see docker-guide. However, for a quick start, we recommend to use the ready-made Docker image as outlined in the section "How to get started" or the Quickstart-Guide.

In order to run NetAScore, you need to prepare a data directory that contains at least the settings file and mode profile files for bike and walk profiles. You find example files in the examples subdirectory of the NetAScore repository. If available, also copy the input data sets and optional data sets to the data subdirectory in your repository root.

As a next step, make sure that you have a (local) PostgreSQL database running and that you specified the correct database connection details in the settings file.

Please find more information on possible options available in the settings file and their meaning in the configuration guide.

Make sure you have installed these software dependencies:

  • Python 3.x
  • recent PostgreSQL with PostGIS extension (make sure to enable all GDAL drivers if prompted; this should include psql, raster2pgsql and ogr2ogr)
  • osm2pgsql (osm2pgsql.org)

After installation of PostgreSQL, please make sure that its subfolder containing the binaries (e.g. Program Files/PostgreSQL/<version>/bin) is added to the PATH environment variable.

Then, install the Python dependencies for this project - e.g. with pip:

RUN pip install -r requirements.txt

Now you can run NetAScore by providing the filename of the settings file as commandline parameter to the Python script:

python generate_index.py your-settings-file.yml

The processing can take several minutes up to several hours - depending on the size of the geodata and the hardware used. Therefore, we recommend to start with a small example first.

Additional commandline parameters

If you want to re-run the pipeline, but skip certain steps, use the --skip flag with a list of steps you want to skip: import, network, attributes, optional, index, export (the steps are explained in detail in this readme file). In the following example, import, network and attributes steps will be skipped and only the export step is re-executed:

python generate_index.py your-settings-file.yml --skip import network attributes

If you want to get more (or less) detailed log outputs, set the --loglevel flag to one of the following levels: 1 = MajorInfo, 2 = Info (default), 3 = Detailed, 4 = Debug