Note

Interactive online version: Binder badge

DLR Urban Traffic Dataset (DLR UT)#

This example should give a short overview on how to load the DLR Urban Traffic Dataset which is hosted on Zenodo.

Download dataset#

At first, we need to download the dataset. For that purpose, the class DLRUTDatasetManager is available in TASI that we will utilize in the following. The class DLRUTVersion is an enumerator that may be used to specify the version of the dataset to download or to get the latest version.

The following example will not download the dataset, but will use a local sample that is available in DATA_PATH. If you want to download the latest version, change to DLRHTVersion.latest and update the path attribute.

[1]:
import os

from tasi.dlr.dataset import DLRUTDatasetManager, DLRUTVersion
from tasi.tests import DATA_PATH

dataset = DLRUTDatasetManager(DLRUTVersion.v1_2_0, path=DATA_PATH)
path = dataset.load()
path
[1]:
PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/tasi/checkouts/stable/tasi/tests/data/DLR-Urban-Traffic-dataset_v1-2-0')

The dataset is now available in the /tmp directory. Let’s have a look into the dataset and list the available traffic information

[2]:
folders = os.listdir(path)
folders
[2]:
['raw_data', 'meta_data']

Load trajectory data#

We can now utilize the tasi.dlr.dataset.DLRTrajectoryDataset class to load the trajectory data from the directory. For demonstration purpose, let’s load the first batch of the dataset.

[3]:
from tasi.dlr import DLRTrajectoryDataset

ds = DLRTrajectoryDataset.from_csv(dataset.trajectory()[0])
ds
[3]:
acceleration position classifications dimension interpolated velocity yaw
easting magnitude northing easting northing bicycle car motorbike pedestrian truck van height length width easting magnitude northing
timestamp id
2023-09-24 12:00:00.016482+00:00 1695556712692966 0.003 0.010 0.009 604755.977 5.793e+06 0.025 0.824 0.150 0.000 0.000 0.000 1.625 2.407 1.334 False 0.004 0.020 0.019 -73.593
1695556715491157 -1.093 1.235 -0.575 604795.259 5.793e+06 0.000 0.883 0.109 0.005 0.003 0.000 1.556 3.463 2.045 False -3.971 4.113 -1.074 -164.869
1695556722944961 -0.000 0.001 0.001 604753.090 5.793e+06 0.000 0.579 0.334 0.000 0.087 0.000 1.682 2.135 1.124 False -0.000 0.008 -0.008 -69.165
1695556743992329 -0.005 0.007 0.006 604751.898 5.793e+06 0.000 0.590 0.060 0.000 0.344 0.000 1.990 2.508 1.565 False -0.012 0.016 0.010 -68.221
1695556773745982 0.013 0.021 0.016 604793.176 5.793e+06 0.002 0.811 0.176 0.011 0.000 0.000 1.366 2.739 1.101 False 0.014 0.026 -0.022 110.513
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2023-09-24 12:14:59.966482+00:00 1695557695944822 -0.626 0.632 -0.085 604725.113 5.793e+06 0.008 0.925 0.056 0.000 0.011 0.000 1.450 2.909 1.466 True 10.926 11.018 1.419 7.340
1695557698396270 0.127 0.327 -0.301 604798.425 5.793e+06 0.000 0.989 0.003 0.006 0.001 0.000 1.472 3.275 1.686 False -4.345 13.879 13.181 108.258
1695557698694887 0.149 0.161 0.061 604810.204 5.793e+06 1.000 0.000 0.000 0.000 0.000 0.000 1.656 0.909 0.497 False -4.130 4.296 -1.184 -163.998
1695557699646115 -0.706 0.709 0.068 604685.307 5.793e+06 0.000 0.996 0.000 0.000 0.000 0.004 1.637 3.301 1.654 False 11.289 11.297 0.410 2.078
1695557700093347 -1.155 1.187 -0.274 604652.341 5.793e+06 0.000 0.692 0.308 0.000 0.000 0.000 1.306 3.873 1.524 True 12.743 12.759 -0.639 -2.968

299053 rows × 19 columns

Note that the Dataset is represented as a pandas.DataFrame since it inherits from it. The index of the Dataset contains the timestamp of a traffic participant’s state and its id as a unique identifier.

The traffic participant’s state include various information, including the boundingbox position, the velocity, dimension and classification type.

Load traffic light data#

The DLR UT dataset also contains information of the traffic lights. We utilize the tasi.dlr.dataset.DLRTrajectoryDataset class to load the information. For demonstration purpose, let’s load the first batch of the dataset.

[4]:
from tasi.dlr import DLRUTTrafficLightDataset

traffic_lights = DLRUTTrafficLightDataset.from_csv(dataset.traffic_lights()[0])
traffic_lights
[4]:
state
timestamp id
2023-09-24 12:00:00.991000+00:00 1 3
2 3
3 5
4 5
5 3
... ... ...
2023-09-24 12:14:59.994000+00:00 26 3
27 3
28 3
29 3
30 1

26910 rows × 1 columns

Load weather data#

The DLR Research Intersection is equipped with a weather station stat collects various information. We can utilize the tasi.dataset.WeatherDataset to load some of this information.

[5]:
from tasi.dlr.dataset import DLRWeatherDataset

weather = DLRWeatherDataset.from_csv(dataset.weather()[0])
weather
[5]:
air_pressure_msl air_temperature dew_point_temperature hail_intensity present_weather rain_accumulation rain_intensity relative_humidity snow_accumulation solar_radiation visibility wet_bulb_temperature wind_direction wind_gust_direction wind_speed
timestamp id
2023-09-24 12:00:00+00:00 DLR 1025.795 19.000 9.606 0.0 NaN NaN NaN 54.017 NaN NaN NaN 13.582 175.0 116.0 2.401
2023-09-24 12:00:10+00:00 DLR 1025.810 19.000 9.467 0.0 NaN NaN NaN 53.967 NaN NaN NaN 13.542 152.0 116.0 3.266
2023-09-24 12:00:20+00:00 DLR 1025.810 19.000 9.467 0.0 0.0 0.0 0.0 53.933 0.0 657.458 20000.0 13.542 172.0 182.0 3.435
2023-09-24 12:00:30+00:00 DLR 1025.810 19.000 9.467 0.0 NaN NaN NaN 53.883 NaN NaN NaN 13.542 175.0 182.0 2.799
2023-09-24 12:00:40+00:00 DLR 1025.810 19.000 9.467 0.0 NaN NaN NaN 53.783 NaN NaN NaN 13.542 199.0 182.0 2.234
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2023-09-24 12:14:10+00:00 DLR 1025.813 18.900 9.282 0.0 NaN NaN NaN 53.633 NaN NaN NaN 13.415 157.0 143.0 2.167
2023-09-24 12:14:20+00:00 DLR 1025.813 18.917 9.282 0.0 0.0 0.0 0.0 53.617 0.0 606.806 20000.0 13.415 124.0 143.0 1.435
2023-09-24 12:14:30+00:00 DLR 1025.813 18.933 9.282 0.0 NaN NaN NaN 53.633 NaN NaN NaN 13.415 123.0 143.0 1.000
2023-09-24 12:14:40+00:00 DLR 1025.813 18.950 9.282 0.0 NaN NaN NaN 53.683 NaN NaN NaN 13.415 130.0 143.0 1.732
2023-09-24 12:14:50+00:00 DLR 1025.813 18.967 9.282 0.0 0.0 0.0 0.0 53.800 0.0 NaN 20000.0 13.415 123.0 143.0 1.102

90 rows × 15 columns

Load air quality data#

Although also collected by the same weather station, information about the local air quality is available via another dataset.

[6]:
from tasi.dlr.dataset import DLRAirQualityDataset

air_quality = DLRAirQualityDataset.from_csv(dataset.air_quality()[0])
air_quality
[6]:
co_gas_concentration coarse_particle_mass_concentration fine_particle_mass_concentration no2_gas_concentration no_gas_concentration o3_gas_concentration so2_gas_concentration
timestamp id
2023-09-24 12:00:20+00:00 DLR 136.88 2.5 1.5 22.944 7.482 96.0 0.0
2023-09-24 12:01:20+00:00 DLR 132.24 2.5 1.5 21.032 7.482 96.0 0.0
2023-09-24 12:02:20+00:00 DLR 128.76 2.5 1.5 19.120 6.235 96.0 0.0
2023-09-24 12:03:20+00:00 DLR 125.28 2.5 1.5 19.120 4.988 98.0 0.0
2023-09-24 12:04:20+00:00 DLR 120.64 2.5 1.5 19.120 4.988 98.0 0.0
2023-09-24 12:05:20+00:00 DLR 116.00 2.5 1.5 19.120 4.988 98.0 0.0
2023-09-24 12:06:20+00:00 DLR 112.52 2.5 1.5 17.208 4.988 98.0 0.0
2023-09-24 12:07:20+00:00 DLR 109.04 2.5 1.5 19.120 3.741 98.0 0.0
2023-09-24 12:08:20+00:00 DLR 105.56 2.5 1.5 17.208 3.741 98.0 0.0
2023-09-24 12:09:20+00:00 DLR 107.88 2.5 1.5 15.296 3.741 98.0 0.0
2023-09-24 12:10:20+00:00 DLR 111.36 2.4 1.5 17.208 3.741 100.0 0.0
2023-09-24 12:11:20+00:00 DLR 110.20 2.4 1.5 17.208 2.494 98.0 0.0
2023-09-24 12:12:20+00:00 DLR 113.68 2.4 1.5 19.120 4.988 98.0 0.0
2023-09-24 12:13:20+00:00 DLR 111.36 2.4 1.5 15.296 3.741 96.0 0.0
2023-09-24 12:14:20+00:00 DLR 107.88 2.4 1.5 13.384 4.988 98.0 0.0

Load road quality information#

The same weather measurement station also collects information about the road condition.

[7]:
from tasi.dlr.dataset import DLRRoadConditionDataset

road_conditions = DLRRoadConditionDataset.from_csv(dataset.road_condition()[0])
road_conditions
[7]:
ice_layer_thickness snow_layer_thickness surface_grip surface_state surface_temperature water_layer_thickness
timestamp id
2023-09-24 12:00:20+00:00 DLR 0.0 0.0 0.82 1.0 26.5 0.00
2023-09-24 12:00:50+00:00 DLR 0.0 0.0 0.82 1.0 26.5 0.00
2023-09-24 12:01:20+00:00 DLR 0.0 0.0 0.82 1.0 26.3 0.00
2023-09-24 12:01:50+00:00 DLR 0.0 0.0 0.82 1.0 26.2 0.00
2023-09-24 12:02:20+00:00 DLR 0.0 0.0 0.82 1.0 26.2 0.00
2023-09-24 12:02:50+00:00 DLR 0.0 0.0 0.82 1.0 26.2 0.00
2023-09-24 12:03:20+00:00 DLR 0.0 0.0 0.82 1.0 26.2 0.00
2023-09-24 12:03:50+00:00 DLR 0.0 0.0 0.82 1.0 26.4 0.00
2023-09-24 12:04:20+00:00 DLR 0.0 0.0 0.82 1.0 26.8 0.01
2023-09-24 12:04:50+00:00 DLR 0.0 0.0 0.82 1.0 26.8 0.01
2023-09-24 12:05:20+00:00 DLR 0.0 0.0 0.82 1.0 26.8 0.01
2023-09-24 12:05:50+00:00 DLR 0.0 0.0 0.82 1.0 26.8 0.01
2023-09-24 12:06:20+00:00 DLR 0.0 0.0 0.82 1.0 26.8 0.01
2023-09-24 12:06:50+00:00 DLR 0.0 0.0 0.82 1.0 26.8 0.01
2023-09-24 12:07:20+00:00 DLR 0.0 0.0 0.82 1.0 26.8 0.01
2023-09-24 12:07:50+00:00 DLR 0.0 0.0 0.82 1.0 26.8 0.01
2023-09-24 12:08:20+00:00 DLR 0.0 0.0 0.82 1.0 26.9 0.01
2023-09-24 12:08:50+00:00 DLR 0.0 0.0 0.82 1.0 26.9 0.00
2023-09-24 12:09:20+00:00 DLR 0.0 0.0 0.82 1.0 26.8 0.00
2023-09-24 12:09:50+00:00 DLR 0.0 0.0 0.82 1.0 25.2 0.00
2023-09-24 12:10:20+00:00 DLR 0.0 0.0 0.82 1.0 25.1 0.00
2023-09-24 12:10:50+00:00 DLR 0.0 0.0 0.82 1.0 24.6 0.00
2023-09-24 12:11:20+00:00 DLR 0.0 0.0 0.82 1.0 24.6 0.00
2023-09-24 12:11:50+00:00 DLR 0.0 0.0 0.82 1.0 25.2 0.00
2023-09-24 12:12:20+00:00 DLR 0.0 0.0 0.82 1.0 25.4 0.00
2023-09-24 12:12:50+00:00 DLR 0.0 0.0 0.82 1.0 25.6 0.00
2023-09-24 12:13:20+00:00 DLR 0.0 0.0 0.82 1.0 25.8 0.00
2023-09-24 12:13:50+00:00 DLR 0.0 0.0 0.82 1.0 25.8 0.00
2023-09-24 12:14:20+00:00 DLR 0.0 0.0 0.82 1.0 25.9 0.00
2023-09-24 12:14:50+00:00 DLR 0.0 0.0 0.82 1.0 26.7 0.00

Load traffic volume data#

The DLR UT dataset contains meta information like traffic volume data that were extracted from the raw trajectory data.

[8]:
from tasi.dlr.dataset import DLRTrafficVolumeDataset

traffic_volume = DLRTrafficVolumeDataset.from_csv(dataset.traffic_volume()[0])
traffic_volume
[8]:
East0South1 East1South1 East2West0 East2West1 East3West0 East3West1 North1South0 South1West1 South2North1 South3East0 South4East1 West0North1 West0West1 West1East0 West2East0 West2East1 West4South1
timestamp id
2023-09-24 00:00:00+00:00 DLR 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2023-09-24 00:00:01+00:00 DLR 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2023-09-24 00:00:02+00:00 DLR 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
2023-09-24 00:00:03+00:00 DLR 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2023-09-24 00:00:04+00:00 DLR 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2023-09-24 00:14:55+00:00 DLR 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2023-09-24 00:14:56+00:00 DLR 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2023-09-24 00:14:57+00:00 DLR 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2023-09-24 00:14:58+00:00 DLR 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2023-09-24 00:14:59+00:00 DLR 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

900 rows × 17 columns

Load OpenSCENARIO files#

The DLR UT dataset contains the trajectory data in OpenSCENARIO format.

[9]:
openscenario_files = dataset.openscenario()
openscenario_files
[9]:
['/home/docs/checkouts/readthedocs.org/user_builds/tasi/checkouts/stable/tasi/tests/data/DLR-Urban-Traffic-dataset_v1-2-0/meta_data/openscenario/openscenario_230924-120000_230924-121500.xosc']

That’s it for now. We hope this page helps you get started 😎