Mechanical Edits/Mateusz Konieczny - bot account/migrating rocks from surface to material

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.

This edit will retag some surface=* tags

Who

I, Mateusz Konieczny using my bot account

contact

message via OSM I will respond also to PMs to the bot account, though messaging my main account is preferable as I will get notifications in OSM editors.

English and Polish languages are preferable, for other I need to use an automatic translator.

What

replace following surface tags by doing an automated edit:

Why

There is noticeable (but not very high) number of surface=granite / surface=marble and other similar tagging type of stone into surface tag.


There was some discussion on https://community.openstreetmap.org/t/type-of-stone-in-surface-surface-granite-and-similar/9424


Surface=granite blocks distinguishing between

etc

surface=granite may be any of following:

Exposed raw rock (surface=rock / surface=raw_rock)

  https://wiki.openstreetmap.org/wiki/File:Half_Dome_ropes_4.jpg

Natural stone machined into a flat surface (surface=paving_stones)

  https://commons.wikimedia.org/wiki/File:Pretty_natural_stone_used_for_paving.jpg

Flattened stone, but still not entirely flat and not covering entire surface (surface=sett) https://commons.wikimedia.org/wiki/File:Granite_Setts.jpg

Raw cobblestone of natural, uncut, rounded stones. (surface=unhewn_cobblestone) https://commons.wikimedia.org/wiki/File:Ancient_road_surface.jpg

Stones or plates individually arranged in a row, allowing to walk on, surrounded by an unpaved medium such as grass or water (surface=stepping_stones) https://commons.wikimedia.org/wiki/File:River_Rothay_stepping_stones_120508w.jpg https://wiki.openstreetmap.org/wiki/File:Stepping_stones_-_geograph.org.uk_-_832601.jpg

surface=gravel and surface=pebblestone and maybe some other would be valid.

(note: specific photos above may be not necessarily depict granite, but `surface=granite` could also take such forms) (if you have a better photo then improving https://wiki.openstreetmap.org/wiki/Tag:surface%3Dgranite would be highly welcome)


So instead of surface=granite using material=granite would be preferable.

For example instead of: highway=pedestrian surface=granite

following tagging would be better: highway=pedestrian material=granite

This makes space for tagging surface=sett or surface=unhewn_cobblestone or surface=paving_stones etc

I think that it would be much better to tag and such migration can be done with an automatic edits.

Edits will be not made where there is already material / paving_stones:material tag with a mismatching info.

Edits will be made where such surface tags are present now or will appear in future.

There are also surface=steel, surface=aluminium and surface=iron but these are trickier and not proposed to be edited here (I guess that leaving surface=metal would be useful and surface=iron should only be changed to surface=metal as it is really unlikely to be correct)

Why it is useful? It helps newbies to avoid becoming confused. It protects against such values becoming established. Without drudgery that would be required from the manual cleanup. It also makes easier to add missing surface= values

Why automatic edit? I have a massive queue (in thousands and tens of thousands) of automatically detectable issues which are not reported by mainstream validators, require fixes and fix requires review or complete manual cleanup.

There is no point in manual drudgery here, with values obviously fixable.

This values here do NOT require manual overview. If this cases will turn out to be an useful signal of invalid editing than I will remain reviewing nearby areas where bot edited.

Yes, bot edit WILL cause objects to be edited. Nevertheless, as result map data quality will improve.

Numbers

Large enough to make it useful to automate it.

How

state after a mechanical edit:

Changeset would be described and tagged with tags that mark it as automatic, provide link to discussion approving edit, include link promoting https://matkoniecz.github.io/OSM-wikipedia-tag-validator-reports/ etc

Discussion

Discussed at talk mailing list at https://lists.openstreetmap.org/pipermail/talk/2023-March/088110.html and tag change was discussed on https://community.openstreetmap.org/t/type-of-stone-in-surface-surface-granite-and-similar/9424

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

Source code

GPL 3.0 licensed

from osm_bot_abstraction_layer.generic_bot_retagging import run_simple_retagging_task

def migrated():
    return {
        'granite': 'granite',
        'granit': 'granite',
        'marble': 'marble',
        'sandstone': 'sandstone',
        'laterite': 'laterite', # hopefully confused, may refer to type of soil or bricks or stone
        'limestone': 'limestone',
        'limerock': 'limerock',
        "chalk": "chalk",
        'basalt': 'basalt',
        #'steel': 'steel',
        #'aluminium': 'aluminium',
        #'iron': 'iron', # maybe better open notes? Surely this bridges are rather steel? Retag to material=metal?
    }

def edit_element(tags):
    for material in migrated():
        if tags.get("surface") == material:
            if tags.get("material") not in [material, None]:
                print("conflict between surface =", material, "and material = ", tags["material"])
                return tags
            if tags.get("paving_stones:material") not in [material, None]:
                print("conflict between surface =", material, "and paving_stones:material = ", tags["material"])
                return tags
            tags.pop("surface")
            tags["material"] = material
            return tags
    return tags

def main():
    for material, replacement in migrated().items():
        print("{{tag|surface|", material, "}} → {{tag|material|", replacement, "}}")
    for material, replacement in migrated().items():
        print("surface", "=", material, "→", "material", "=", replacement)
    query = """
[out:xml][timeout:1800];
("""
    for material in migrated().keys():
        query += "nwr[surface='" + material + "'];\n"
    query += """
);
out body;
>;
out skel qt;
"""
    run_simple_retagging_task( # (area.a)
        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='move rock types to material from surface, as for example surface=granite may describe surface=unhewn_cobblestone and surface=sett and surface=paving_stones and raw rock surface',
        discussion_url='https://lists.openstreetmap.org/pipermail/talk/2023-March/088110.html',
        osm_wiki_documentation_page='https://wiki.openstreetmap.org/wiki/Mechanical_Edits/Mateusz_Konieczny_-_bot_account/migrating_rocks_from_surface_to_material',
        edit_element_function=edit_element,
    )

if __name__ == "__main__":
    main()

"""
There is noticeable (but not very high) number of surface=granite /
surface=marble and other similar tagging type of stone into surface tag.

-------------------------------------------------------------------------------

There was some discussion on
https://community.openstreetmap.org/t/type-of-stone-in-surface-surface-granite-and-similar/9424

-------------------------------------------------------------------------------

Surface=granite blocks distinguishing between

surface=paving_stones
surface=sett
surface=unhewn_cobblestone
surface=rock
etc

surface=granite may be any of following:

Exposed raw rock (surface=rock / surface=raw_rock)
   https://wiki.openstreetmap.org/wiki/File:Half_Dome_ropes_4.jpg

Natural stone machined into a flat surface (surface=paving_stones)
   https://commons.wikimedia.org/wiki/File:Pretty_natural_stone_used_for_paving.jpg

Flattened stone, but still not entirely flat and not covering entire
surface (surface=sett)
https://commons.wikimedia.org/wiki/File:Granite_Setts.jpg

Raw cobblestone of natural, uncut, rounded stones.
(surface=unhewn_cobblestone)
https://commons.wikimedia.org/wiki/File:Ancient_road_surface.jpg

Stones or plates individually arranged in a row, allowing to walk on,
surrounded by an unpaved medium such as grass or water
(surface=stepping_stones)
https://commons.wikimedia.org/wiki/File:River_Rothay_stepping_stones_120508w.jpg
https://wiki.openstreetmap.org/wiki/File:Stepping_stones_-_geograph.org.uk_-_832601.jpg

surface=gravel and surface=pebblestone and maybe some other would be
valid.

(note: specific photos above may be not necessarily depict granite, but
`surface=granite` could also take such forms) (if you have a better
photo then improving
https://wiki.openstreetmap.org/wiki/Tag:surface%3Dgranite would be
highly welcome)

-------------------------------------------------------------------------------

So instead of surface=granite using material=granite would be
preferable.

For example instead of:
highway=pedestrian surface=granite

following tagging would be better:
highway=pedestrian material=granite

This makes space for tagging surface=sett or surface=unhewn_cobblestone
or surface=paving_stones etc

I think that it would be much better to tag and such migration can be
done with an automatic edits.

So I am proposing following replacements:

surface = granite → material = granite
surface = granit → material = granite
surface = marble → material = marble
surface = sandstone → material = sandstone
surface = laterite → material = laterite
surface = limestone → material = limestone
surface = limerock → material = limerock
surface = chalk → material = chalk
surface = basalt → material = basalt

Edits will be not made where there is already material /
paving_stones:material tag with a mismatching info.

Edits will be made where such surface tags are present now or will
appear in future.

There are also surface=steel, surface=aluminium and surface=iron but
these are trickier and not proposed to be edited here (I guess that
leaving surface=metal would be useful and surface=iron should only be
changed to surface=metal as it is really unlikely to be correct)

Why it is useful? It helps newbies to avoid becoming confused. It
protects against such values becoming established. Without drudgery
that would be required from the manual cleanup. It also makes easier to
add missing surface= values

Why automatic edit? I have a massive queue (in thousands and tens of
thousands) of automatically detectable issues which are not reported by
mainstream validators, require fixes and fix requires review or
complete manual cleanup.

There is no point in manual drudgery here, with values obviously
fixable.

This values here do NOT require manual overview. If this cases will
turn out to be an useful signal of invalid editing than I will remain
reviewing nearby areas where bot edited.

Yes, bot edit WILL cause objects to be edited. Nevertheless, as result
map data quality will improve. 
"""

Opt-out

Please write at bot approval thread. Note that in case of opt-out exactly the same edit will be made manually for objects where bot opt-out was used.