1

Hello

Background knowledge

I am totally new to the topics of GIS. I have just started looking into this so my knowledge on topics such as mapnik and postgis is not that high.

Question

I am trying to remove administrative boundaries for countries that currently extend into the sea/ocean. I am looking to achieve country boundaries that look similar to openstreetmaps transport layer which show no water boundaries.

Setup

The way I am rendering the map tiles is using mapnik. I have followed this tutorial exactly: https://switch2osm.org/manually-building-a-tile-server-16-04-2-lts/

Attempted Solutions

I researched this question before asking and these were the possible solutions that I came across and the end result.

(1) I have tried to change the query in mapnik.xml that controls the admin_boundaries and added a new parameter: boundary=administrative AND NOT boundary_type=maritime. This did not render any results for me in the boundaries. Data set was azerbaijan.osm.pbf from tutorial

(2) https://github.com/gravitystorm/openstreetmap-carto/issues/621 has a query that should remove water boundaries from the map written by nebulon42 but it leaves certain boundaries in water intact. Tested using myanmar.osm.pbf

(3) https://help.openstreetmap.org/questions/34000/problem-hidding-a-maritime-border-with-mapnik suggests changing the ordering of the rendering but I do not know how to do that so I was unable to test this one.

Current Solution

I am removing the way tags from the osm file that correspond to the boundaries and replacing them with latitude and longitude acquired from https://wambachers-osm.website/boundaries/ and selecting land. In a small sample size it has worked but I am wondering if there is an easier way to do so from mapnik.xml either using a specific query or tag.

Any help is appreciated and Thank you.

asked 20 Dec '17, 15:47

Ujjawal's gravatar image

Ujjawal
31226
accept rate: 0%

edited 03 Jan '18, 20:33

1

Suggest that you make this edit an answer, and then an admin (e.g. me) can make this the accepted answer). I think it will be clearer.

(03 Jan '18, 17:18) SK53 ♦

ok removed the edit for an answer

(03 Jan '18, 20:34) Ujjawal

2 Answers:
1

How prevalent is the "maritime=yes" tag? If that's in widespread use (and in the few places I've looked it does seem to be used properly) you can just remove an admin boundary tag in lua if maritime=yes is set.

Here is a bit of lua code that removes all boundaries. You want something instead like:

if (( keyvalues["boundary"] == "administrative" )  and
    ( keyvalues["maritime"] == "yes"            )) then
   keyvalues["boundary"] = nil
end

Whilst you could try and do things with mapnik z-ordering or external boundary info, that sounds very much like "doing it the hard way" to me!

(edit)

If you're wondering "what is a lua and why would I want one", it's a way of changing one tag to another before loading into a rendering database. The OSM Carto style uses this lua transformation, but it doesn't do much in the way of tag changes. You can see some tile-server setup notes using a a style that does much more here.

permanent link

answered 20 Dec '17, 21:04

SomeoneElse's gravatar image

SomeoneElse ♦
33.0k65343778
accept rate: 16%

edited 20 Dec '17, 21:10

I tried to replace the style.lua file provided by the tutorial with yours and it let me remove ALL boundaries but the modified keyvalues[maritime] did remove any boundaries. I checked the osm.xml file that I use to populate the postgres tables and it does have borders that have maritime tags as yes.

(21 Dec '17, 16:28) Ujjawal

I am trying to remove the water boundaries now using osmfilter by trying to remove all ways with tags on maritime=yes and border_type=territorial based on the information written in http://wiki.openstreetmap.org/wiki/Tag:boundary%3Dmaritime but it still seems to keep water boundaries on provincial levels (admin_level > 4). It produces the same result as nebulon42's query from attempted solution 2.

(21 Dec '17, 20:55) Ujjawal

Re the lua suggestion, you're correct that it doesn't work - and the reason is that there are 3 or more objects passed through for rendering for each bit of boundary. There's the way (which has maritime=yes on it) and one or more relations (which don't). These can be removed or retagged with lua but what isn't currently possible is to remove (or change) relation members from within the lua code. There's something a bit like it (the old-style multipolygon handling) but what osm2pgsql actually does with that is a bit of a black art :) It would be possible to change tags on the whole relation based on the members' tags, but that wouldn't help.

(23 Dec '17, 13:12) SomeoneElse ♦
0

So in the end I managed to solve it by using the current solution. This is basically for anyone else who wants to use this method (Note: not the most efficient solution)

(1) Download the country osm.xml file

(2) remove all boundary=administrative tags (used osmfilter but use whichever tool that gets the job done).

(3) download the country file from https://wambachers-osm.website/boundaries/ and choose the json format and land boundary.

(4) Download a tool to convert geojson to osm.xml format (used geojsontoosm but note if you use this you will have to make a little changes to the code. Things to change are changing the relation id to start from a positive number and ++ increment as relations as negative dont display and add an extra tag that forces boundary = administrative in multipolygon method. And if you need lvl4(admin_level) data remove the part where it doesnt add way to relation if you have only one entry in multipolygon)

(5) add the new osm.xml in the original country xml. (I just made a script for it as you would need to remove the osm tags from the new osm.xml and remove the ending osm tag from the bottom of country tag and for multiple countries it would be a hassle to do manually.)

Hope it helps someone and Thanks to someoneElse for lua idea.

permanent link

answered 03 Jan '18, 20:32

Ujjawal's gravatar image

Ujjawal
31226
accept rate: 0%

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×322
×111
×52

question asked: 20 Dec '17, 15:47

question was seen: 2,488 times

last updated: 03 Jan '18, 20:34

powered by OSQA