Mechanical Edits/Mateusz Konieczny - bot account/remove paved key duplicating surface key

From OpenStreetMap Wiki
Jump to navigation Jump to search

Page content created as advised on Automated_Edits_code_of_conduct#Document_and_discuss_your_plans.

Who

I, Mateusz Konieczny using my bot account

contact

message via OSM I will respond also to PMs to the bot account. In both cases I will be notified about incoming PMs via email and notifications in OSM editors.

What

Remove paved=yes and paved=no where it duplicates surface=*.

Why

For example paved=yes present where surface=asphalt is adds no useful info.

Removing it will result in less confusing tagging and bring more clarity to newbies (both newbies in editing raw tags and newbies in using data).

Also, it stops very pointless duplication of values - and prevents potential future confusing when situation changed and tagging is updated. In such cases, especially if more complex changed were applied it is complicated to detangle what is going on. And for now this change is easy to perform for at least some objects.

Also, it makes easier to manually investigate remaining cases. And that was how this proposal was triggered - after several cases where human brain was not really needed I looked into it and scale is large enough to make mass edit worthwhile.

Yes, it is not among critical or the most important issues in the world or just in the OSM. But it is also very easy to fix, so overall effort/benefit ratio is decent.

Offtopic

If you are aware of problems with better effort/benefit ratio in OSM, especially ones that require primarily programming, feel free to give me ideas. I have already huge list and not enough time to do them as a hobby, but maybe some new idea is better than what I have already. (and for some that take far more time then I can spend as a hobby I am looking for potential funding)

Numbers

Depends on how many new matches appear - depends on editing activity in OSM.

How

Each changeset contains a single element or group of close elements to avoid edits spanning across large areas (it is impossible in cases where edited object itself spans very large area)

Changeset would be described and tagged with tags that mark it as automatic, provide link to documentation page etc

Editing would be worldwide.

Example of state before a mechanical edit:

state after a mechanical edit:

Bot source code

Bot is using https://github.com/matkoniecz/osm_bot_abstraction_layer library, this code is GNU GPLv3 licensed

code for my bots resides in https://codeberg.org/matkoniecz/OpenStreetMap_cleanup_scripts/src/branch/master/recurrent_bot_edits

from osm_bot_abstraction_layer.generic_bot_retagging import run_simple_retagging_task
import osm_bot_abstraction_layer.human_verification_mode
import osm_bot_abstraction_layer.tag_knowledge as tag_knowledge
import rich

"""
https://community.openstreetmap.org/t/surface-duplicated-by-paved-bot-edit-proposal/138817

surface= duplicated by paved= - bot edit proposal

there are some `paved=no` combined with surface values such as say `surface=dirt` that indicate that surface is not paved

there are some `paved=yes` combined with surface values such as say `surface=asphalt` that indicate that surface is paved

I propose to remove such `paved=` values as not needed - and likely to cause confusion if someone would retag `surface=`

`paved=` without `surface=` will not be edited

`paved=` conflicting with `surface=` will not be edited
"""

def edit_element(tags):
    if tags.get("paved") == "yes":
        if tags.get("surface") in tag_knowledge.paved_road_surfaces():
            tags.pop('paved', None)
            return tags
        else:
            rich.print(tags)
    return tags

def main():
    query = """
[out:xml][timeout:1800];
(
"""
    query += "  nwr[paved=yes];\n"
    query += """);
out body;
>;
out skel qt;
"""
    run_simple_retagging_task(
        max_count_of_elements_in_one_changeset=500,
        objects_to_consider_query=query,
        cache_folder_filepath='/media/mateusz/OSM_cache/osm_bot_cache',
        is_in_manual_mode=True,
        changeset_comment='remove not needed paved=yes duplicating normal surface= tag',
        discussion_url=None,
        osm_wiki_documentation_page=None,
        edit_element_function=edit_element,
    )

main()


def edit_element(tags):
    if tags.get("paved") == "no":
        if tags.get("surface") in tag_knowledge.unpaved_road_surfaces():
            tags.pop('paved', None)
            return tags
        else:
            rich.print(tags)
    return tags

def main():
    query = """
[out:xml][timeout:1800];
(
"""
    query += "  nwr[paved=no];\n"
    query += """);
out body;
>;
out skel qt;
"""
    run_simple_retagging_task(
        max_count_of_elements_in_one_changeset=500,
        objects_to_consider_query=query,
        cache_folder_filepath='/media/mateusz/OSM_cache/osm_bot_cache',
        is_in_manual_mode=False,
        changeset_comment='remove not needed paved=no duplicating normal surface= tag',
        discussion_url="https://community.openstreetmap.org/t/surface-duplicated-by-paved-bot-edit-proposal/138817",
        osm_wiki_documentation_page="https://wiki.openstreetmap.org/w/index.php?title=Mechanical_Edits/Mateusz_Konieczny_-_bot_account/remove_paved_key_duplicating_surface_key",
        edit_element_function=edit_element,
    )

main()

Discussion

https://community.openstreetmap.org/t/surface-duplicated-by-paved-bot-edit-proposal/138817

Repetition

This is reoccurring edit and may be made as soon as new matching elements appear. At this moment triggering new edit requires human intervention so exact schedule is not predictable and bot may stop running at any moment.

This can change in a future. If bot is abandoned and does not run, feel free to ping me. If I am unable to run it any more feel free to use my code. Note that it may require going through bot approval process again and that code is on specific license.

https://codeberg.org/matkoniecz/OpenStreetMap_cleanup_scripts/src/branch/master/recurrent_bot_edits may have more up to date code version that what is listed on this page

Opt-out

Please write at forum topic where it was discussed .

Note that in case of opt-out exactly the same edit will be made manually.