📜 ⬆️ ⬇️

Map of the accident

image

Let me tell you about the “Roadmap” project - an interactive map of accidents in Russia. The map simplifies the analysis of accidents and helps to find the real causes of accidents. How did you get the idea where they took the data and why they opened the source code.

For 2018 in the accident on the roads of Russia killed 19088 people



The figure is decreasing with each passing year, but it still remains much larger than in developed countries, where much more attention is paid to the problem of road mortality. A great example is the Swedish road safety program Vision Zero.

The basic principle of the program is the inadmissibility of fatal traffic accidents. This principle is also called the principle of "zero tolerance", according to it, it is impossible to treat death on the road as the inevitable evil associated with motorization. - wikipedia

Last year, the Urban Projects of Ilya Varlamov and Maxim Kats Foundation launched the Zero Deaths campaign in Moscow. The idea is that in principle no one should die in an accident. And if people die, it is not the victims, but first of all the designers, the builders, or the city. It is necessary to understand every accident, find system causes and gradually eliminate them. While the city departments are not seriously engaged in this.

Therefore, last summer, we with city activists and Moscow municipal deputies were puzzled by the creation of a tool that would allow for a detailed spatial analysis of road accidents: find dangerous intersections, study local statistics on streets and cities, identify the main factors and causes of accidents. At that time, such a public project did not exist.

Open data on accidents


We are very lucky with open data. On Habré already wrote good posts to work with them. Such attention is fully justified - this is one of the most detailed and interesting data that the state now discloses. Coordinates, weather, brands and years of release cars, breaking the rules, the gender of the participants and much more. And that's all for each of more than 600 thousand accidents.

In this case, we were worried about the stat.gibdd.ru service itself . Despite the detailed data under the hood, it differs in that it is very inconvenient for use. It is more like a website for officials: a comparison to the APPG (for the same period last year), the details are only up to the administrative units, the traffic accidents are displayed in a list.

image

Such an interface and functionality is not at all suitable for people, but rather created for official reports.

Creating a portal


An important role in creating the technical assignment was played by people who actually face these problems - deputies, activists, urbanists. It was thanks to them that they got to understand what was really needed. We agreed on a small starting budget of 30 thousand rubles and started to do it.

Working with data began with the fact that I wrote a simple parser of regions and accidents from the traffic police portal site. We clung to their API, which gave the data to the service itself, and unloaded it. As I wrote above, there are posts on this topic on Habré, and the source code of our parser can be found in the repository .

The main problem was geocoding, since many of the accidents had incorrect coordinates. Coordinates are very different from the addresses. For example, in Makhachkala, 90% of the accidents were generally out of the city, and in Barnaul, part of the accidents simply slid into the woods.

image

In the beginning, we used Yandex.Geocoder, but their limitations and the refusal to share the service even for a non-commercial project led to the fact that we had to find another solution. As a result, we set our task on the hackathon of social projects PublicData, where the guys made their custom solution, which not only finds the nearest address, but also the nearest road.

image

The guys took the address as the priority coordinate, and if the geotach from the protocol is removed from it by more than 300 meters, the algorithm will not take it into account. The algorithm is that we take the building's geo-point and project it onto the road, we do the same with the geo-point from the protocol. Between the two resulting points we draw a segment. The middle of this segment will be the point we need.

Next we used the postgresql + django + djangorestframework stack. The data was hierarchical, so we had to create additional tables for the values ​​for which we planned filters.

On the front-end, we planned an interactive map with filters and automatically calculated statistics. The main task was to make sure that the map did not hang with so many objects (Moscow has more than 30 thousand). The result was a ReactJS application with a leaflet add-in. It loads from the API at once all the accidents of a region or city, but only those that appear on the screen show on the map. This made the starting page load quite long, but provided quick filtering and recalculation of statistics, and does not allow the map to slow down. In addition, a little later, we added a heat layer that is activated at a certain scale and with too many accidents. In the beginning we only had a map of Moscow.

We refused the mobile version at the first stage, since it will be hard to put the main functions in there, and the key user histories of working with the map suggest immersion for analysis, and not something that people will do on the go.

We selected the filters by their importance for the analysis: types of accidents, dates, streets, traffic violations, surrounding infrastructure.



We also noticeably simplified and improved the accident card with the help of colors, icons, panoramas.

image

Result


For half a year the project was visited by a little more than 30 thousand people who viewed the site about 100 thousand times. Now the map is developing together with activists in the regions, who talk about road traffic crashes on the example of a map of their city and region. They communicate with regional media and talk about the problem in their blogs: Kirov on the "Roadmap". Top-7 streets of the city where most of the accidents occurred , Vladimir on the people's road accident map , “You must be guided by the safety of people”: an accident map was created in the Nizhny Novgorod region .

We receive individual feedback on the project. For example, the Urban Projects Foundation actively uses our portal to conduct its research on dangerous intersections. At the “Kirov Urban Forum” our project was mentioned as an argument for revising the urban planning policy. We are very pleased that we have at least some influence on the problem.

Source


If you went to the project site, you should have noticed that the project still has many problems, of which:


To get more people involved in the project, we opened the project source code . There is an instruction on how to raise the project at your place, how to download data and tasks, solving which you can help the project.

In the near future we have fixed some small bugs and finalize the project.

At the moment on the map: Moscow, St. Petersburg, Kazan, Nizhny Novgorod, Krasnodar, Yaroslavl, Kirov, Vladimir, Cheboksary and their regions.

If the project helps to save at least one life out of these 20 thousand, then all this was not in vain. You also have the opportunity to save several lives. We will be very happy if you:


Thanks to everyone who participated in the creation of the project, and especially: Alexey Radchenko, Anastasia Romashkevich, Anton Chernykh c13 , Alexander Popovtsev, Anna Kirichenko, Konstantin Nabatchikov, Vladislav Prud, Maxim Nikityuk.

Source: https://habr.com/ru/post/438700/