Tell the mayor where to go (using Open Street Map)

 3r3406. 3r3-31.
Do not you think that our officials are somewhat divorced from reality? What is not enough to look at the controlled territory solely from the office window in the city center? What would it be nice for the city head to walk around the city personally from time to time, to communicate with people and answer questions in the mode of live communication? 3r33395. 3r33333.  3r3406.
So it seemed to the well-known blogger Ilya Varlamov, too, so he launched the coolest project with the defiant name BDSM, and named “Big Road With The Mayor” (3r-3? reference 3r-?394. To the announcement): 3r-3395. 3r33333.  3r3406. 3r33352. Stop walking alone in Russian cities - it's time to invite mayors, governors, city managers. 3r33333.  3r3406. 3r33333.  3r3406. The rules are simple. 3r33333.  3r3406. 3r33333.  3r3406. The computer randomly selects two addresses in your city. After that we go for a walk from one address to another. Condition one: do not use the car. Only legs, bicycle, public transport, scooter, dog sled. No preparation, no approval of the route. Sometimes the walks will be long, through the whole city, sometimes you have to walk just a few blocks in the center. This is the main condition: without showing off, without preparation. 3r33333.  3r3406. 3r33333.  3r3406. In the course of the walk, we, together with the head of the city, study the infrastructure, communicate with the residents. The official will have a unique opportunity to tell the whole of Russia about his city, to explain the subtleties of city management, to get closer to the people! 3r33333.  3r3406. 3r33333. 3r33333.  3r3406. 3r330. 3r33333.  3r3406.
A shot from the first video of the project, with the participation of my service for selecting random points
3r33395. 3r33333.  3r3406.
What does it have to do with Habr, you ask? And the whole thing in the phrase about a random choice of the address of the beginning and end of the route. This is not an easy task if you don’t want to end up in the wilds of any industrial zone or get lost in the endless fences of the private sector. Simply poking a card with a blindfold will not work here! 3r33395. 3r33333.  3r3406.
About how I solved this problem and what discoveries gave me such cities as Ivanovo or Kirov - under the cut. (seriously, if you need to work with a simple 2D geometry in your project, then allows you to do everything very quickly and not to steam with creating your own editors or using any heavy GIS applications). 3r33395. 3r33333.  3r3406.
Tell the mayor where to go (using Open Street Map) Marked Kirov, with marked center (yellow), manually removed areas (red) and added piece (green)
3r33395. 3r33333.  3r3406.
Thus, the first version of the algorithm was ready in two days and the testing time began. And here reefs have got. 3r33395. 3r33333.  3r3406.
3r33333. The private sector
3r33395. 3r33333.  3r3406.
Under the terms of the problem, the route should not begin and end in the private sector. By my naivety, a resident of a large city could not have imagined that private wooden houses could be on a nearby street from the central square of the city. And not a couple of monuments of antiquity, like ours, but naturally whole blocks. 3r33395. 3r33333.  3r3406.
Fighting these quarters took most of the time. At first I tried to do pure OSM data. There is a special meaning of the residental = rural tag to denote the countryside and landuse = allotments for all kinds of gardening. 3r33395. 3r33333.  3r3406.
3r3183. 3r33333.  3r3406.
Yes, even in St. Petersburg there are built-in gardening in the city line
3r33395. 3r33333.  3r3406.
However, it quickly became clear that these tags are set quite rarely, and are usually satisfied only with the most common landuse = residental (residential area). 3r33395. 3r33333.  3r3406.
The next step was an attempt to weed out such quarters manually. I added support for manual removal of areas to the geojson file with the city center. Unfortunately, it quickly became clear that a bunch of iterations of the cycle "loaded the map - looked at the eyes - found the private sector - cut it out in - loaded again" takes a lot of time, especially in cities where private houses go along with high-rise buildings and are scattered in small groups and here. For example, in Ivanovo
3r33333.  3r3406.
Private and apartment buildings are densely mixed with each other just a couple of blocks from the center of 3r-3291. 3r33395. 3r33333.  3r3406.
I had to invent an empirical algorithm. I took a quarter (landuse = residental area, although there is no direct requirement for its use, usually it is not marked by the whole city or district, but by separate quarters), I took all the buildings within its borders (polygons with the building tag) and considered the average area of ​​such a landfill. If it was less than 400m2 (the figure was taken from the ceiling, with the condition of coarse marking and counting and individual long houses found in such quarters), then the quarter was considered the private sector and was thrown out of the calculations. 3r33395. 3r33333.  3r3406.
As a result, the combination of these three methods made it possible to more or less effectively filter out unwanted areas, although not without the involvement of manual labor. 3r33395. 3r33333.  3r3406.
But of course then there were exceptions. For example, Evpatoria, where in general the entire historical center is in essence the narrow streets of the private sector. If you throw it all away, there will be nothing left of the city. 3r33395. 3r33333.  3r3406.
The typical landscape of Evpatoria is a couple of hundred meters from the sea.
3r33395. 3r33333.  3r3406.
Especially for such cases, we had to add to GeoJSON not only the manually deleted sectors of the city, but also the manually added ones. Those. even if the quarter did not fall under other conditions, it was still included in the list of searchable points. 3r33395. 3r33333.  3r3406.
3r33333. Industrial zones and commercial sites
3r33395. 3r33333.  3r3406.
With industrial zones, everything is much easier than with the private sector. As a rule, they are already marked up with the landuse = industrial tag and there are no problems with them. Unless there are some exceptions, when not all blocks are laid out, but separate buildings. But since I used the ready-made code for working with maps from Sight Safari in the project, it was already taken into account there. 3r33395. 3r33333.  3r3406.
Landuse = retail had to be tricky with commercial sites. As in half of the cases, large markets or shopping centers are laid out in this way, and in the second half, wholesale warehouses are somewhere on the outskirts, or in general cargo terminals where no entry is allowed. Standardization, as usual, is lame. Fortunately, there are quite a few such zones, this tag is not very popular, so it was not difficult to deal with them manually. 3r33395. 3r33333.  3r3406.
At the same time I added to my list of funny place names that are often found in industrial zones. For example in Yaroslavl there is a brake street. If I lived there, I would definitely start an office there for my IT office. 3r33395. 3r33333.  3r3406.
3r33333. Cartographic Surprise
3r33395. 3r33333.  3r3406.
Although I already had some experience with OSM, it was still constantly emerging that something new. 3r33395. 3r33333.  3r3406.
For example, Yaroslavl had an open external contour. Visually, it looks closed, but refers to missing nodes and lines. Possible export problem. 3r33395. 3r33333.  3r3406.
A lot of addiction was found within the boundaries of cities. In my naivety, I thought that the border of a city is always a simple closed broken line. But no. 3r33395. 3r33333.  3r3406.
There are cities with holes. For example Obninsk. That is, the piece inside the city is really not administratively owned by him. 3r33395. 3r33333.  3r3406.
Obninsk with a hole
3r33395. 3r33333.  3r3406.
There are cities consisting of several unrelated areas, such as Kirov. And if on average there are several blocks of Kirov, then the left, the smallest one, is just a piece of the road leading to the airport and four houses. What was the salt cut such a piece and attach it to the city? 3r33395. 3r33333.  3r3406.
Kirov consists of three unrelated areas
3r33395. 3r33333.  3r3406.
For sure if the BDSM program will continue and I will continue to participate in it - I will get acquainted with some other non-trivial cartographic situations that I cannot imagine right now. 3r33395. 3r33333.  3r3406.
3r33333. Problems with the layout of maps
3r33395. 3r33333.  3r3406.
A couple of words about OSM markup. 3r33395. 3r33333.  3r3406.
In the last cities that I processed, I was faced with the fact that people do not put landuse tags, or put them somehow. In fact, a person who is far from IT may not be very clear about the deep meaning of these tags. Well, if you think about it, they change the color of the map (gray residential areas, pink industrial areas, etc.), it would seem to be unprincipled. And therefore many treat them rather casually. 3r33395. 3r33333.  3r3406.
However, in my opinion, the power of OSM lies precisely in the ability to machine processing large amounts of data, such as what I did here or in Sight Safari. There are a lot of cards on the Internet, but I don’t know any more cards with the ability to deflate all the geometry and tags and use them freely in my algorithms. And just for such purposes, these tags begin to play an important role. Since almost always the tasks look like “find something there in areas of a certain type”, and the landuse tag is the first and easiest way to identify and find the necessary areas. 3r33395. 3r33333.  3r3406.
The same, but to a lesser extent, applies to a bunch of other tags, for example specifying the type of use (well, it's not just a residential area, but a low-rise building). They are often not bothered to bet, probably because they do not see in them a great benefit. Indeed, if you use only navigators and online maps, they are not thereare visible. But it is for machine processing of map data that they can give valuable hints and simplify algorithms. 3r33395. 3r33333.  3r3406.
In general, put the tags, gentlemen! Oh please! 3r33395. 3r33333.  3r3406.
And yes, on the basis of the problems found, I myself went over the maps and added some tags. So the community benefits from this project too. 3r33395. 3r33333.  3r3406.
3r33333. So where did I send the mayor?
3r33395. 3r33333.  3r3406.
Since I did not take part in the shooting itself, and most of my work was completed before the shooting of the first episode, I had to be content with the same fragmentary information from public sources as everyone else. 3r33395. 3r33333.  3r3406.
In general, it was a bit dumb, if my algorithm would lead them completely into some kind of wilderness. It became especially dumb when I read this here in 3r33340. post 3r3r94. about Ivanovo:
3r33333.  3r3406. 3r33352. Vladimir Sharypov, the mayor of the city, left a pleasant impression. An open and frank person. I would say too frank for the official. The conversation turned out to be interesting. Went to Sort, where a meeting with some voters took place spontaneously. 3r33333.
3r33395. 3r33333.  3r3406. 3r33352. All anything, but at 14 o'clock on the Sorting there are no sober. Under the terms of the show, the mayor must walk unguarded. I even thought at some point that there would be a fight, as some citizens were obviously in inadequate condition. But the cost. 3r33333.
Well, finally came the first series on the channel, you can watch. 3r33395. 3r33333.  3r3406. 3r33358.
3r33333. 3r33333. 3r3402. 3r3402. 3r3402. 3r33333.  3r3406.
When the algorithm chose Tovarny Lane on the Evpatoria map, it seemed to Illya that doubts crept in, in any case he asked if the mayor was afraid. The name is something that immediately casts thoughts about some gloomy abandoned factories, dirty roads and dark personalities with a heavy look (forgive me, residents of Evpatoria, if this is not so). 3r33395. 3r33333.  3r3406.
3r33333. Conclusion
3r33395. 3r33333.  3r3406.
Work on this project was interesting. Without leaving home, I went on a small trip through the cities of my country, izlazil them with a magnifying glass in all possible maps and got acquainted with the local cartographic coloring. Along the way, I also finalized the Sight Safari code. 3r33395. 3r33333.  3r3406.
As you can see, it’s not such a trivial task to dig into maps and choose random points. And for every obvious algorithm, life is ready to give you a dozen cities where it does not work. 3r33395. 3r33333.  3r3406.
As an advertisement: I am doing all this right now on the basis of 3r33387. Institute of Design and Urbanism
in itmo. We are doing there a lot of interesting pieces related to IT and urban data, if someone is interested in this topic - come to us to study for a magistracy or work. 3r33395. 3r33333.  3r3406.
During the preparation of the project, the code and experience of the project 3r-33393 was actively used. Sight Safari
- Navigator to search for tourist routes. 3r33395. 3r3402. 3r3406. 3r3406. 3r33399. ! function (e) {function t (t, n) {if (! (n in e)) {for (var r, a = e.document, i = a.scripts, o = i.length; o-- ;) if (-1! == i[o].src.indexOf (t)) {r = i[o]; break} if (! r) {r = a.createElement ("script"), r.type = "text /jаvascript", r.async =! ? r.defer =! ? r.src = t, r.charset = "UTF-8"; var d = function () {var e = a.getElementsByTagName ("script")[0]; e. ): d ()}}} t ("//"""_mediator") () (); 3r33400. 3r3406. 3r3402. 3r3406. 3r3406. 3r3406. 3r3406.
+ 0 -

Add comment