Mechanical Edits/Mateusz Konieczny - bot account/remove boundary tagging on ways in Poland/

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 remove unneded boundary=administrative tags that are duplications causing warning in validators.


I, Mateusz Konieczny using my bot account


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.


Removing boundary=administrative tags from ways in Poland, except cases where also admin_level=* is present. Only ways belonging to boundary=administrative relation will be edited.


boundary=administrative + admin_level=* on ways, duplicating boundary=administrative + admin_level=* on relations is likely an outdated tagging that should be eliminated. (but see discussion).

boundary=administrative without admin_level=* on ways, duplicating boundary=administrative + admin_level=* on relations is tagging

  • without any known benefits
  • raising validator warnings in JOSM, Vespucci, Osmose and probably also other QA tools
  • that is pointless duplication

Note also that tagging boundary=administrative + admin_level=* on ways is not needed and useful anymore anyway

  • with exception of very rare data consumers like an abandoned ÖPNVKarte where such boundaries are of minor importance


Unknown, let me know if it is important to someone.


An example (note that way belongs to relations such as [1] [2] [3] [4]):
state before a mechanical edit:

state after a mechanical edit:

Changeset would be described and tagged with tags that mark it as automatic, provide link to discussion approving edit etc


Discussed by Polish OSM community at

Thread specifically about bot edit:


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

Source code

GPL 3.0 licensed

from osm_bot_abstraction_layer.generic_bot_retagging import run_simple_retagging_task
import osm_bot_abstraction_layer.overpass_downloader as overpass_downloader
from osm_iterator.osm_iterator import Data
import osm_bot_abstraction_layer.world_data as world_data
import time

def edit_element(tags):
    if tags.get('admin_level') != None:
        return tags
    if tags.get('boundary') != ("administrative"):
        return tags
    tags.pop('boundary', None)
    return tags

def query(area_name):
  return """
area['name'='""" + area_name + """']->.searchArea;
out meta qt;"""

def storage_path(filename):
  return '/tmp/' + filename

def edit_part(area_name):
        objects_to_consider_query= query(area_name),
        changeset_comment='usunięcie zbędnego boundary=administrative z lini, dublującego tagi na relacjach granic',

def main():
    #edit_part("Warszawa") #for test run
    # following turned out to be not needed
    code = "PL"
    admin_level_of_split = 4
    storage_file = storage_path(code+"_area_divisions.osm")
    for area_name in world_data.list_of_area_divisions(code, admin_level_of_split, storage_file):
      minutes_sleeping = 3 # to avoid overloading overpass
      time.sleep(60 * minutes_sleeping)



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.

See also