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 import DLRTrajectoryDataset
from tasi.dlr.dataset import DLRHTDatasetManager, DLRHTVersion

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

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

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

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(['acceleration', 'center', 'classifications', 'dimension',
       'interpolated', 'velocity', 'yaw'],
      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]:
bicycle car motorbike pedestrian truck van
timestamp id
2024-10-07 10:10:00.004659+00:00 1728295526844377 0.009 0.000 0.000 0.030 0.961 0.000
1728295531312857 0.000 0.000 0.000 0.000 1.000 0.000
1728295544518602 0.000 0.000 0.000 0.011 0.989 0.000
1728295551063398 0.000 0.000 0.000 0.000 1.000 0.000
1728295556167395 0.000 0.000 0.000 0.010 0.988 0.000
... ... ... ... ... ... ... ...
2024-10-07 10:14:59.954659+00:00 1728296097703409 0.000 0.000 0.000 0.008 0.977 0.000
1728296098124967 0.000 0.094 0.000 0.000 0.183 0.723
1728296098425027 0.000 0.005 0.000 0.000 0.646 0.349
1728296099329685 0.000 0.746 0.013 0.000 0.150 0.092
1728296099789271 0.000 0.774 0.002 0.000 0.132 0.093

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

364813 rows × 20 columns

You can achieve the same result by directly calling

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

364813 rows × 20 columns

This works similarly for all object classes.

[14]:
ds.trucks
[14]:
acceleration center classifications dimension interpolated velocity yaw
easting magnitude northing signed easting northing bicycle car motorbike pedestrian truck van height length width easting magnitude northing
timestamp id
2024-10-07 10:10:00.004659+00:00 1728295526844377 0.383 0.469 0.271 -0.567 614332.566 5791112.259 0.009 0.000 0.0 0.030 0.961 0.000 3.672 15.586 2.998 False -20.742 22.369 -8.376 -157.843
1728295531312857 -0.003 0.147 0.147 -0.047 614446.945 5791161.157 0.000 0.000 0.0 0.000 1.000 0.000 3.966 16.076 3.049 False -20.845 22.863 -9.392 -155.917
1728295544518602 0.036 0.134 0.129 -0.107 614706.614 5791290.385 0.000 0.000 0.0 0.011 0.989 0.000 3.717 15.590 2.982 False -19.603 22.401 -10.841 -151.282
1728295551063398 -0.156 0.261 0.209 0.036 614418.037 5791145.027 0.000 0.000 0.0 0.000 1.000 0.000 3.968 15.658 3.052 False -22.196 24.008 -9.150 -157.714
1728295556167395 0.053 0.178 0.170 -0.175 614758.189 5791318.716 0.000 0.000 0.0 0.010 0.988 0.000 3.487 6.215 2.623 False -20.897 23.975 -11.752 -150.527
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2024-10-07 10:14:59.954659+00:00 1728296089444833 0.005 0.194 0.194 0.165 614527.342 5791181.027 0.000 0.000 0.0 0.017 0.970 0.000 3.423 11.449 2.951 False 20.420 22.676 9.861 25.971
1728296093961123 -0.142 0.244 0.198 -0.205 617524.995 5796003.032 0.000 0.000 0.0 0.005 0.956 0.039 2.897 6.735 2.251 False -8.853 28.018 -26.582 -108.424
1728296095670219 -0.048 0.410 0.407 0.212 614478.363 5791159.839 0.000 0.000 0.0 0.000 0.812 0.188 2.570 7.426 2.263 False 29.155 32.348 14.014 25.655
1728296097703409 -0.008 0.293 -0.293 -0.218 616906.261 5794225.851 0.000 0.000 0.0 0.008 0.977 0.000 3.943 16.023 3.154 False 8.879 23.783 22.063 68.319
1728296098425027 0.144 0.144 0.003 -0.033 616595.411 5793526.287 0.000 0.005 0.0 0.000 0.646 0.349 2.466 6.323 2.342 False -11.554 28.171 -25.692 -114.428

218763 rows × 20 columns