Seeking Guidance: Correcting Admin Boundaries and Roads in Custom OSM Deployment

Hi OSM Community,

We’ve successfully deployed our own OSM instance using the community Docker image, and our goal is to correct some map data—specifically, polygons, roads, and lines. Our focus is on adjusting features related to admin_level=* and boundary='administrative' with accurate polygons and boundary lines.

Currently, we’re connecting QGIS to the database to identify and delete erroneous data via queries in tables like planet_osm_polygon and planet_osm_roads. However, we’re facing challenges with adding corrected polygons and boundary lines directly through SQL. I’ve also tried using JOSM for editing, but I couldn’t find a straightforward approach, especially for adding new data.

Additionally, I suspect my deletion method is incomplete, as certain features persist in planet_osm_point. Could anyone guide me on the best approach for this workflow or recommend tools and steps for correctly adding, updating, and deleting map data?

Thanks in advance for your help!

I’m assuming you are running an osm2pgsql schema database and mainly want to use it for rendering?

My strategy (if I had to abide by some regulation that tries to make the world different from how it actually is) would be to not render the offending objects at all from the data in the “synchronized” OSM data and instead modify the map style to use static data (that completely could reside in the same database), that could either be from a third party source, or simply a suitable table generated from OSM data in which you have in a 2nd step adapted the data to conform to your expectations.

PS: if you find a bona fide aka non-political issue with a road you should simply fix it in OSM proper.

3 Likes

What issues might arise if I delete certain boundaries or data directly from the main OSM database tables (like planet_osm_polygon or planet_osm_line)? Are there any potential impacts on the rendering process, database integrity, or future data updates that I should consider

For completeness, the answers to your previous question also address this one.

However, @SimonPoole’s answer above is probably the easiest to implement of what has been suggested so far.

1 Like

Any minor change in OSM that affects any of the objects you have deleted, will make them re-appear in your database.

1 Like

As @woodpeck has pointed out the update mechanism will reinstate the current version every time the data is changed in OSM proper. You can partially workaround this with a lot of effort (database triggers etc), but IMHO it doesn’t make any sense when there is a simple and most importantly robust solution.

1 Like


How can I deal with data that has incorrect boundaries? I understand that I can either hide them or avoid rendering them, as you mentioned, @SimonPoole. However, I’m also looking to create new boundaries. I’ve tried using QGIS to create a LineString layer and applied some merging algorithms, but it hasn’t worked as expected. Any advice on the best approach for this?

Firstly, please stop talking about “incorrect” boundaries; here in OSM we believe that our boundaries are as “correct” as possible. So from our perspective, what you want to do is remove OSM’s “correct” boundaries and replace them by “incorrect” boundaries to placate some government or some nationalist group. It is ok for you to do that but you shouldn’t insult us by calling our data “incorrect”.

Secondly, I would very much advise you to stop any meddling with OSM boundaries in the PostGIS tables and, as advised in Seeking Guidance: Correcting Admin Boundaries and Roads in Custom OSM Deployment - #2 by SimonPoole, change your map style to load boundaries from a separate source (which could be a shape file you have created in QGIS; perhaps from naturalearthdata.com or a differnt source or even, if you want, based on a pgsql2shp export of current boundaries from your PostGIS table).

4 Likes

I apologize if my previous message came across as disrespectful. I appreciate the hard work that goes into OSM’s data, and I didn’t mean to imply any negative judgment.

Communication does not seem to be occurring, so maybe an example would help. Here is a map of mine without boundaries. There are no boundaries shown there because the map style for that map layer simply has the features that would display as admin boundaries removed before they are displayed. You can either do that in lua as I do in that example, or (perhaps easier for you) just remove the display of admin boundaries from that map style.

Great! You know have a map with no admin boundaries.

Here is a map with admin boundaries. The admin boundaries there come from a different database using a map style that only shows admin boundaries. All the code for that map layer is here. That loads data from OSM, but in your case you’ll want to instead construct source data that you want to load according to the legal fiction you want to follow.

In my example the admin boundaries map layer can be turned on and off by the user, but it doesn’t have to be like this; the user doesn’t need to know that there are multiple map layers and databases involved at all. You can, of course, update data in the main OSM database without any change to the boundaries at all, since they are sourced from elsewhere.

This may still all sound a bit too complicated, and if that is the case you might want to consider paying someone else to do it.

3 Likes

Thank you! I really appreciate your help