Note

Interactive online version: Binder badge

Using the DLRHTDataset#

This example shall give an overview of the methods and attributes that are available in the DLRHTDataset class.

Load trajectory data#

At first, we need to load the trajectory data of the dataset.

[1]:
from tasi.dlr.dataset import DLRHTDatasetManager, DLRHTVersion
from tasi.dlr import DLRTrajectoryDataset

dataset = DLRHTDatasetManager(DLRHTVersion.latest)
dataset.load()

ds = DLRTrajectoryDataset.from_csv(dataset.trajectory()[50])
[2025-04-25 12:46:27 | dataset.py:load:112] > INFO:  Checking if dataset already downloaded /tmp/DLR-Highway-Traffic-dataset_v1-1-0
[2025-04-25 12:46:27 | dataset.py:load:138] > INFO:  Dataset already available at /tmp/DLR-Highway-Traffic-dataset_v1-1-0

Attributes of the dataset#

There are several attributes available to get information about a dataset. For instance, we can get the interval of a dataset via the property

[2]:
ds.interval
[2]:
Interval(2024-10-07 10:10:00.004659+00:00, 2024-10-07 10:14:59.954659+00:00, closed='right')

or all unique timestamps of it via

[3]:
ds.timestamps
[3]:
DatetimeIndex(['2024-10-07 10:10:00.004659+00:00',
               '2024-10-07 10:10:00.054659+00:00',
               '2024-10-07 10:10:00.104659+00:00',
               '2024-10-07 10:10:00.154659+00:00',
               '2024-10-07 10:10:00.204659+00:00',
               '2024-10-07 10:10:00.254659+00:00',
               '2024-10-07 10:10:00.304659+00:00',
               '2024-10-07 10:10:00.354659+00:00',
               '2024-10-07 10:10:00.404659+00:00',
               '2024-10-07 10:10:00.454659+00:00',
               ...
               '2024-10-07 10:14:59.504659+00:00',
               '2024-10-07 10:14:59.554659+00:00',
               '2024-10-07 10:14:59.604659+00:00',
               '2024-10-07 10:14:59.654659+00:00',
               '2024-10-07 10:14:59.704659+00:00',
               '2024-10-07 10:14:59.754659+00:00',
               '2024-10-07 10:14:59.804659+00:00',
               '2024-10-07 10:14:59.854659+00:00',
               '2024-10-07 10:14:59.904659+00:00',
               '2024-10-07 10:14:59.954659+00:00'],
              dtype='datetime64[ns, UTC]', name='timestamp', length=6000, freq=None)

or the ids of all traffic participants in the dataset.

[4]:
ds.ids
[4]:
Index([1728295526844377, 1728295531312857, 1728295544518602, 1728295551063398,
       1728295556167395, 1728295560193834, 1728295564123267, 1728295565972843,
       1728295578507359, 1728295583632382,
       ...
       1728296095670219, 1728296095853169, 1728296096271015, 1728296096335768,
       1728296096509785, 1728296097703409, 1728296098124967, 1728296098425027,
       1728296099329685, 1728296099789271],
      dtype='int64', name='id', length=353)

Filtering#

If you want to look into a short sequence of the overall dataset, you can select specific rows of the overall dataset. The DLRTrajectoryDataset provides various ways for this purpose.

Time and object#

There are two variants to filter a dataset based on the information on the dataset’s index. For instance, if you want to filterthe dataset by an interval, you can utilize the during method

[5]:
ds.during(ds.timestamps[0], ds.timestamps[10])
[5]:
center velocity acceleration yaw dimension classifications interpolated
easting northing easting northing magnitude easting northing magnitude signed length width height pedestrian bicycle motorbike car van truck
timestamp id
2024-10-07 10:10:00.004659+00:00 1728295526844377 614332.566 5791112.259 -20.742 -8.376 22.369 0.383 0.271 0.469 -0.567 -157.843 15.586 2.998 3.672 0.030 0.009 0.000 0.000 0.000 0.961 False
1728295531312857 614446.945 5791161.157 -20.845 -9.392 22.863 -0.003 0.147 0.147 -0.047 -155.917 16.076 3.049 3.966 0.000 0.000 0.000 0.000 0.000 1.000 False
1728295544518602 614706.614 5791290.385 -19.603 -10.841 22.401 0.036 0.129 0.134 -0.107 -151.282 15.590 2.982 3.717 0.011 0.000 0.000 0.000 0.000 0.989 False
1728295551063398 614418.037 5791145.027 -22.196 -9.150 24.008 -0.156 0.209 0.261 0.036 -157.714 15.658 3.052 3.968 0.000 0.000 0.000 0.000 0.000 1.000 False
1728295556167395 614758.189 5791318.716 -20.897 -11.752 23.975 0.053 0.170 0.178 -0.175 -150.527 6.215 2.623 3.487 0.010 0.000 0.000 0.000 0.000 0.988 False
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2024-10-07 10:10:00.454659+00:00 1728295796508847 616768.111 5793896.440 23.457 55.888 60.611 0.315 1.049 1.095 1.190 67.012 3.021 1.612 1.459 0.000 0.000 0.352 0.648 0.000 0.000 False
1728295796672015 617285.590 5795275.613 -8.853 -26.599 28.034 -0.166 -0.268 0.315 0.127 -108.288 4.078 1.807 1.614 0.000 0.000 0.000 0.736 0.218 0.045 False
1728295798853449 617550.802 5796093.530 -6.728 -24.111 25.032 -0.332 -0.848 0.911 1.104 -105.774 4.551 1.785 1.451 0.000 0.000 0.025 0.790 0.037 0.148 False
1728295799090058 614405.409 5791129.981 45.975 19.681 50.010 -0.186 0.693 0.717 0.187 23.098 4.798 1.916 1.395 0.000 0.000 0.012 0.782 0.030 0.176 False
1728295799691936 616609.087 5793555.456 -10.013 -22.096 24.259 0.449 0.855 0.966 -1.436 -114.312 11.921 2.936 3.258 0.040 0.001 0.000 0.000 0.000 0.959 False

960 rows × 20 columns

that returns the rows within the given interval.

Another variant to select specific rows of the datasets is by the id of a traffic participant. This might be useful if you want to take a closer look into the behavior of specific traffic participants. For instance, to filter by the second traffic participant in the dataset, we can combine the ids attribute with the trajectory method.

[6]:
ds.trajectory(ds.ids[1])
[6]:
center velocity acceleration yaw dimension classifications interpolated
easting northing easting northing magnitude easting northing magnitude signed length width height pedestrian bicycle motorbike car van truck
timestamp id
2024-10-07 10:10:00.004659+00:00 1728295531312857 614446.945 5791161.157 -20.845 -9.392 22.863 -0.003 0.147 0.147 -0.047 -155.917 16.076 3.049 3.966 0.0 0.0 0.0 0.0 0.0 1.0 False
2024-10-07 10:10:00.054659+00:00 1728295531312857 614445.903 5791160.687 -20.846 -9.384 22.861 -0.002 0.149 0.149 -0.048 -155.935 16.076 3.049 3.966 0.0 0.0 0.0 0.0 0.0 1.0 False
2024-10-07 10:10:00.104659+00:00 1728295531312857 614444.860 5791160.217 -20.847 -9.377 22.858 -0.002 0.150 0.150 -0.050 -155.953 16.076 3.049 3.966 0.0 0.0 0.0 0.0 0.0 1.0 False
2024-10-07 10:10:00.154659+00:00 1728295531312857 614443.817 5791159.747 -20.847 -9.369 22.856 -0.002 0.152 0.152 -0.052 -155.972 16.076 3.049 3.966 0.0 0.0 0.0 0.0 0.0 1.0 False
2024-10-07 10:10:00.204659+00:00 1728295531312857 614442.775 5791159.278 -20.848 -9.361 22.853 -0.001 0.153 0.153 -0.053 -155.990 16.076 3.049 3.966 0.0 0.0 0.0 0.0 0.0 1.0 False
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2024-10-07 10:10:07.704659+00:00 1728295531312857 614287.889 5791094.572 -19.413 -7.585 20.842 0.481 0.313 0.574 -0.555 -158.349 16.076 3.049 3.966 0.0 0.0 0.0 0.0 0.0 1.0 False
2024-10-07 10:10:07.754659+00:00 1728295531312857 614286.919 5791094.193 -19.389 -7.569 20.814 0.481 0.313 0.574 -0.562 -158.362 16.076 3.049 3.966 0.0 0.0 0.0 0.0 0.0 1.0 False
2024-10-07 10:10:07.804659+00:00 1728295531312857 614285.950 5791093.815 -19.364 -7.554 20.786 0.481 0.313 0.574 -0.562 -158.375 16.076 3.049 3.966 0.0 0.0 0.0 0.0 0.0 1.0 False
2024-10-07 10:10:07.854659+00:00 1728295531312857 614284.983 5791093.438 -19.340 -7.538 20.757 0.481 0.313 0.574 -0.562 -158.388 16.076 3.049 3.966 0.0 0.0 0.0 0.0 0.0 1.0 False
2024-10-07 10:10:07.904659+00:00 1728295531312857 614284.016 5791093.061 -19.316 -7.522 20.729 0.481 0.313 0.574 -0.562 -158.401 16.076 3.049 3.966 0.0 0.0 0.0 0.0 0.0 1.0 False

159 rows × 20 columns

Traffic participant properties#

There are also methods available that might help to find the relevant information in the dataset. The most straight forward option is to use pandas’ capability to access specific attributesof the datasets. The available attributes on the dataset, are available via theattribute` property.

[7]:
ds.attributes
[7]:
Index(['center', 'velocity', 'acceleration', 'yaw', 'dimension',
       'classifications', 'interpolated'],
      dtype='object')

We can, for instance, access the traffic participants center position.

[8]:
ds.center
[8]:
easting northing
timestamp id
2024-10-07 10:10:00.004659+00:00 1728295526844377 614332.566 5791112.259
1728295531312857 614446.945 5791161.157
1728295544518602 614706.614 5791290.385
1728295551063398 614418.037 5791145.027
1728295556167395 614758.189 5791318.716
... ... ... ...
2024-10-07 10:14:59.954659+00:00 1728296097703409 616906.261 5794225.851
1728296098124967 616711.520 5793759.411
1728296098425027 616595.411 5793526.287
1728296099329685 615956.485 5792379.564
1728296099789271 617309.156 5795338.293

615546 rows × 2 columns

or the classification propabilities.

[9]:
ds.classifications
[9]:
pedestrian bicycle motorbike car van truck
timestamp id
2024-10-07 10:10:00.004659+00:00 1728295526844377 0.030 0.009 0.000 0.000 0.000 0.961
1728295531312857 0.000 0.000 0.000 0.000 0.000 1.000
1728295544518602 0.011 0.000 0.000 0.000 0.000 0.989
1728295551063398 0.000 0.000 0.000 0.000 0.000 1.000
1728295556167395 0.010 0.000 0.000 0.000 0.000 0.988
... ... ... ... ... ... ... ...
2024-10-07 10:14:59.954659+00:00 1728296097703409 0.008 0.000 0.000 0.000 0.000 0.977
1728296098124967 0.000 0.000 0.000 0.094 0.723 0.183
1728296098425027 0.000 0.000 0.000 0.005 0.349 0.646
1728296099329685 0.000 0.000 0.013 0.746 0.092 0.150
1728296099789271 0.000 0.000 0.002 0.774 0.093 0.132

615546 rows × 6 columns

We extended these basic capabilities with additional methods, that, for instance, allow to get the most likely class by each traffic participant’s pose

[10]:
ds.most_likely_class(by='pose')
[10]:
timestamp                         id
2024-10-07 10:10:00.004659+00:00  1728295526844377    truck
                                  1728295531312857    truck
                                  1728295544518602    truck
                                  1728295551063398    truck
                                  1728295556167395    truck
                                                      ...
2024-10-07 10:14:59.954659+00:00  1728296097703409    truck
                                  1728296098124967      van
                                  1728296098425027    truck
                                  1728296099329685      car
                                  1728296099789271      car
Length: 615546, dtype: object

or by the overall trajectory (the default), i.e. all poses of a traffic participants.

[11]:
ds.most_likely_class(by='trajectory')
[11]:
id
1728295526844377    truck
1728295531312857    truck
1728295544518602    truck
1728295551063398    truck
1728295556167395    truck
                    ...
1728296097703409    truck
1728296098124967      van
1728296098425027    truck
1728296099329685      car
1728296099789271      car
Length: 353, dtype: object

This might help to filter the dataset to select only traffic participants that are classified as a car. To archieve this, we first get the most likely class per trajectory, select the rows having the value ‘car’ and pass their index (the traffic particpant’s id) into the trajectory method of the Dataset.

[12]:
classification = ds.most_likely_class(by='trajectory')

ds.trajectory(classification[classification == 'car'].index)
[12]:
center velocity acceleration yaw dimension classifications interpolated
easting northing easting northing magnitude easting northing magnitude signed length width height pedestrian bicycle motorbike car van truck
timestamp id
2024-10-07 10:10:00.004659+00:00 1728295588170489 615222.831 5791628.789 -19.421 -15.062 24.578 -0.292 0.007 0.292 0.353 -142.015 4.653 1.917 1.477 0.000 0.0 0.011 0.750 0.116 0.123 False
1728295604956765 617522.392 5795945.625 9.456 29.634 31.106 -0.072 -0.026 0.076 0.017 72.249 4.010 1.704 1.359 0.000 0.0 0.078 0.816 0.010 0.095 False
1728295612173647 617495.967 5795862.288 8.931 27.768 29.169 0.064 0.127 0.142 0.173 72.291 3.863 1.749 1.403 0.000 0.0 0.028 0.836 0.027 0.109 False
1728295631882716 614460.933 5791163.675 -24.647 -11.264 27.098 0.279 0.340 0.440 -0.577 -155.297 4.716 1.789 1.453 0.001 0.0 0.007 0.803 0.096 0.094 False
1728295632905553 614441.242 5791153.855 -21.985 -9.864 24.096 0.394 0.362 0.535 -0.568 -155.865 4.376 1.840 1.559 0.000 0.0 0.029 0.783 0.110 0.077 False
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2024-10-07 10:14:59.954659+00:00 1728296094935595 617528.784 5796019.956 -7.446 -26.394 27.424 -0.073 -0.104 0.127 0.099 -105.860 4.674 1.967 1.808 0.000 0.0 0.000 0.492 0.340 0.167 False
1728296096271015 614497.128 5791171.891 35.293 16.544 38.978 -0.332 0.298 0.446 -0.040 24.889 4.619 1.844 1.425 0.000 0.0 0.029 0.790 0.062 0.118 False
1728296096509785 616934.552 5794302.962 14.570 34.756 37.686 0.060 0.034 0.069 0.319 67.642 4.185 1.812 1.558 0.000 0.0 0.000 0.906 0.051 0.044 False
1728296099329685 615956.485 5792379.564 -18.766 -25.421 31.597 -0.572 -0.254 0.625 0.615 -126.478 4.660 1.935 1.503 0.000 0.0 0.013 0.746 0.092 0.150 False
1728296099789271 617309.156 5795338.293 -11.838 -32.888 34.954 0.144 0.110 0.181 -0.261 -109.727 4.281 1.864 1.549 0.000 0.0 0.002 0.774 0.093 0.132 False

364813 rows × 20 columns