From OpenStreetMap Wiki
Jump to navigation Jump to search

Changes by User:SvenR 20th dec 2008

User:SvenR added some recommendations on when not to use the layer tag, about which I partly disagree:

Do not tag areas like landuse, natural etc. with a layer. These areas usually act as a kind of background color in the maps, so the renderers put those colored shapes in the back, painting things like roads in front of them. Interfering with a layer tag might affect this process, thus hiding ways and nodes which would otherwise be visible.

While I agree to not tag landuse etc., the last phrase suggests not to do it because it could interfere with the rendering. However, a renderer not ignoring layer on landuse would surely be a bug in the renderer, because it has no meaning there, right? (Besides some edge cases we cannot nicely model yet anyhow, like forests on large bridges).
You agree not to use layer on areas. Fine. Does the motivation for not doing it matter then? SvenR 21:07, 23 January 2009 (UTC)

Do not tag waterways like rivers, streams etc. with a layer just because you have a bridge running above them and do not want the bridge to be layer=1. Tagging a long river with a layer=-1 tag might affect many existing waycrossings of this river, e.g. tunnels which are layer=-1 themselves. Tagging just the bridge does affect the bridge (putting it above the river when rendering), and nothing else. ...and... Remember: The layer tag has no meaning for absolute heights. The bridge within a perfectly flat street should be layer=1 even if the stream is as far below it as the grand canyon. The track on top of Mount Everest would be layer=0 even though it is 8848 meters above sealevel.

This seems self-contradictory: If layer has no meanings for absolute heights, then it doesn't matter whether to put the layer on the stream or the bridge, and whether to choose layer=-1 for the bridge and layer=-4 for the stream, or 1 and 0 resp.
Of course layer is relative, and you could tag the waterway as layer=-5 and the bridge as layer=-4, but usually the waterway will not be split into a small piece "under the bridge" and "everything else", so the layer=-5 applies to the whole waterway - and that is bad. SvenR 21:07, 23 January 2009 (UTC)
I don't see why it is bad. Can you point out the reason?--Fernando Trebien (talk) 13:27, 14 March 2014 (UTC)
some reasons:
  • "so the layer=-5 applies to the whole waterway" - this would potentially affect crossings hundreds of miles away, nasty. Suddenly the river would run through underground railway networks in some city downstreams which happend to also use layer=-5.
  • while you could in theory have a bridge without explicit layer tag and the river/road bellow with layer=-X and no bridge/tunnel, this makes it harder than necessary to check correctness. The convention is that the way with the bridge/tunnel should also have the layer tag and not the other way. Following this convention would make it easier for validators to warn about errors such as when someone accidentally applies the bridge or culvert to the wrong section of the way.
  • it is enough waste of dataspace and effort to split one way in three pieces to insert a tunnel/bridge, there is usually no reason to split the other way in three pieces as well.
RicoZ (talk) 14:03, 14 March 2014 (UTC)
Adding layer=1 to every bridge actually takes more work and more database space than applying a single layer=-1 to the river. In my city (Porto Alegre), this translates to 54 extra layer tags for bridges vs only 1 for the river. JOSM's validator SHOULD alert when a river with layer=-1 crosses a way without bridge=*, but unfortunately doesn't.--Fernando Trebien (talk) 14:39, 14 March 2014 (UTC)

Additionally, layer=0 is identified with the natural surface level (previously normal ground level), both of which seem to be difficult to define consistently. I can imagine several landscapes, where it is difficult to define such a "natural surface level".

Go ahead and let your imagination run free. We can then clarify if these landscapes are likely to be tagged and impose difficulties. SvenR 21:07, 23 January 2009 (UTC)

There seems to be a lot of disagreement on the details of the meaning of layer. My understanding of (and opinion on) the situation is the following:

  • layer only makes sense on physical objects.
  • Only the relative order is important, not the actual values used, so there is nothing wrong with non-consecutive layers (e.g. object with layer=4 directly over object with layer=-2), and bridges having negative and tunnels having positive layers.
I would find it very odd tagging bridges with negative or tunnels with positive layer numbers. Although this might seem to work in the renderers, it feels wrong nevertheless. Just think about what would happen if somebody adds another way with layer=0 there. SvenR 21:07, 23 January 2009 (UTC)
  • The default value (i.e. the one to be used when no layer tag is present) is layer=0.
  • layer is only ever relevant on intersecting objects. This is not only true when comparing Mt. Everst and Grand Canyon, but also for two parallel roads directly besides each other, having the same height above sea level, but having different layers (for whatever reason); as long as they don't intersect, it says nothing about their relative height.
  • layer is a property introduced because our data model does not support 3D modelling. It should be treated as independent to all other properties, especially bridge=yes and tunnel=yes, even if it is partially redundant (as often ordering can be deduced even without layer). As such, it should always be present wherever two physical features intersect, i.e. no two intersecting physical objects should be tagged with the same layer (nor not tagged with layer at all). This allows deducing the geometry of our data by looking only at the coordinates and the layer tag, and nothing else.

Comments? --Schuetzm 14:36, 10 January 2009 (UTC)

My english is not very good, but if i understood everything right, i completely agree with Schuetzm. --TEL0000 15:34, 10 January 2009 (UTC)
I perfectly agree with your understanding of layer. IMO, however, the second and third citation are not self-contradictory. Their intention seems to be to discourage changing the layer of existing long ways (such as rivers) -- not because of layer semantics, but because this might affect existing intersections. --Tordanik 15:44, 10 January 2009 (UTC)
I think you've got the general concept right, but the terminology wrong. If two ways 'intersect', they have to be at the same layer. Bridge spans do not intersect rivers. Roads intersect each other at a junction. You'd be better off using 'cross.' --Alexrudd 16:51, 23 January 2009 (UTC)
I use the "layer" key on all bridges and tunnels. Usually this means layers 1 and -1, respectively, but it gets more complicated in urban environments. Rivers through cities typically get layer=-1 because they consistently pass under the street level. Bridges over such rivers are often layer=0, especially if they have intersecting streets immediately at one or both ends of the bridge. The same is true when a motorway is below street level. And when a motorway or rail line is consistently above street level, the whole thing gets "layer=1" and not just the parts that are actually on bridges. I also try to make both parts of a divided highway be on the same layer (assuming they're physically at the same level) and make the transition from one layer to another at about the same point. Generally speaking, for any two features that cross or are very close to each other, I try to represent the relative physical height difference. Not only is this a good semantic representation of the physical world, but doing it this way (as opposed to bare-minimum use of the layer key) tends to produce slightly better map renders. That's a win-win. Vid the Kid 23:07, 13 April 2009 (UTC)
While it is nice to represent the "relative physical height difference", the layer tag is for something different and should not be used to describe physical height difference under any circumstances. Perhaps there should be tags like "raised". RicoZ (talk) 10:36, 13 October 2013 (UTC)

Is layer required for bridges, tunnels, and waterways?

For all that this page says, it doesn't actually say when to use it.

Could we decide once and for all whether layer is required for bridges, tunnels, etc? If it is not required, then renderers (and other tools) must interpret bridges as being above any highway=*'s, that tunnels are below anything else, and that when a highway crosses a waterway (with no junction), with no layer tags present, that the highway is passing *over* the waterway (presumably with an unmarked culvert present).

Thoughts? Stevage 14:05, 15 December 2009 (UTC)

I think that there is no need for layer tag everywhere where it can have sane defaults otherwise it will make more mess than good as everyone could interpret layer tag otherwise and it would do more harm than good. --Lafriks 14:14, 15 December 2009 (UTC)

Anyone want to add to or comment on this table:

Way A Way B With junction? Interpretation
bridge=yes Any highway, water... No Bridge is higher.
tunnel=yes Anything. No Tunnel is lower.
highway=* waterway=* No Road crosses over waterway, by unspecified means.
power=line Anything. No Powerline is higher.

Stevage 15:43, 15 December 2009 (UTC)

While this might be workable in most places, what'll happen when you find two homes with boat launches on opposite sides of a waterway?
Although one could envision an increment of 0.5 for bridge and a decrement of 0.5 for tunnel, there isn't a good way to know whether that was the reality or a new editor's misinterpretation or accident (e.g. joining ways causing values to be inherited). Maplint, Keep Right, and others can use layer=* to help confirm and enforce routing ability that might not be evident on a two dimensional rendering. --goldfndr 17:58, 15 December 2009 (UTC)
I would say that if you need to tell the difference in layers, such as when having several bridges, or in the rare case a power line goes under a bridge, than you need to use layer. If there is no need to tell what is above or under what, as for example a road through a forest, than there are no reason to use it. --Skippern 19:15, 15 December 2009 (UTC)
Right, there are solutions to weird cases. But the topic here is "do you need to specify layers for standard cases like bridges over roads?" Stevage 15:22, 16 December 2009 (UTC)

Water can cross a road at-grade. But you have to fix or repair it daily :) --NE2 11:09, 16 December 2009 (UTC)

Of course, but that would not be the default. Use a waterway=ford tag there. Stevage 15:22, 16 December 2009 (UTC)
You mean highway=ford? --Skippern 16:11, 16 December 2009 (UTC)

Please see Proposed_features/default_layer_for_bridge_and_tunnel - Set default layer=1 for bridge=yes and layer=-1 for tunnel=yes

Should layers only consider crossing/intersecting ways or also ways close by?

Here is a related example i'd like to hear your opinion about. The bridge crosses a not yet mapped river and is currently layer 1. now when you zoom out, it overlaps the secondary road which it IMO shouldn't, it's physically the same height. Now there are 2 possible solutions i can think of:

  • Apply layering not only to crossing objects but also to objects that are close nearby, in this case, get the bridge and the secondary road on the same layer which they physically are.
  • Make renderers perform way intersection/crossing analysis so they internally treat the bridge only above layer 0 ways it actually crosses, not above the layer 0 secondary road.

Any opionions on this matter? --Mike` 19:09, 16 April 2011 (BST)

Your first choice would lead to a problem when another road crosses over L3214 nearby. This isn't an easy rendering issue, but it is a rendering issue, and should not be fixed by changing tagging. Layers have nothing to do with relative height, only heights with respect to the (very) local ground level. --NE2 21:46, 16 April 2011 (BST)
Layers are only for relative heights (of intersecting features). They tell me whether something is above else, but not whether it is 1 m or 100 m above that thing, or how high is it above the ground, or what ele=* it has. So I'm somewhat confused by your statement, but assume that I'm probably just misreading it. Regardless, I also consider this ultimately a rendering issue. Unlikely to be fixed soon, though, because afaik no 2D renderer uses intersection checks like that. --Tordanik 22:22, 16 April 2011 (BST)
What I mean to say is that whether the layer is positive or negative means that it is above or below the ground. But the ground is far from flat, so "physically the same height" has no meaning for layer tags. --NE2 07:06, 17 April 2011 (BST)

layer=-1 erroneously used for many italian rivers

For some reason many rivers and creeks in the area that I am looking at (Trentino, River Sarca) are tagged like that. The rivers and creeks are definitely normal mountain river/creeks not in tunnels or underground. I have posted a message to but as my italian is rather basic I would appreciate if other folks could have any eye on this. RicoZ (talk) 12:35, 24 September 2013 (UTC)

Hello RicoZ. You can fix the situation in a small area (such as a city) simply by removing the layer tag from those rivers. If you're using JOSM, simply search for "type:way waterway=* layer=-1", then select "layer=-1" in the Tags/Memberships panel and delete it. Afterwards, JOSM's validator should tell you where bridges/tunnels are missing. You can do the same for larger areas, but you should consult with your local community before doing anything. You can use Osmupdate to download an up-to-date version of the area, then run Osmfilter to select only the waterways. Then you can load the result in JOSM and remove the layer tag. You will probably have to handle several conflicts in JOSM when uploading as there may be lots of people editing those rivers.--Fernando Trebien (talk) 14:18, 14 March 2014 (UTC)
Fortunately an Italian user took care of it. Unfortunately there are still people adding layer=-1 to whole rivers for some reasons (rather frequently to avoid keepright and JOSM warnings about missing bridges) RicoZ (talk) 14:31, 14 March 2014 (UTC)
The best way to avoid this forever is to change the validation rule: it should alert whenever a waterway=* crosses a highway=* that has no tunnel=* or bridge=*, regardless of layer=*. The only exception is if both share a node with highway=ford.--Fernando Trebien (talk) 14:41, 14 March 2014 (UTC)
That is a good idea. Some time ago I have opened tickets for JOSM validator and keepright to warn about waterways which have a layer=-1 without a valid reason so if you consider them valid you can leave your opinion there (JOSM trac supports voting with the arrows).
I think I will also open tickets to have the test rules changed the way you suggested. RicoZ (talk) 14:58, 14 March 2014 (UTC)
RicoZ (talk) 14:58, 14 March 2014 (UTC)

Maximum recommended segment length of ways tagged with layer

Ways tagged with layer=-2,-1,1,2 should be as short as possible. Layers +/- 3,4 could be used for extremely long bridges and tunnels. Recommend a maximum length of 1.2 km (0.75 mi) or the length of a single bridge/tunnel for ways tagged with layer values -2,-1,1,2.

Substantially longer bridges or tunnels should use layers +/- 3 or 4.

Validators should warn if longer segments are newly tagged longer than this rule.


  1. layers 1 and 2 are expected to have a local effect mostly for a single crossing. The 1.2 km should be enough even for larger intersections or a series of small intersections.
  2. tagging long ways in one piece with a particular layer value can affect crossings potentially hundreds of kilometers away. It would require checking all existing crossings that could be theoretically affected and validators can only warn about errors if all data along the complete tagged way is downloaded.
  3. frequently very long ways are tagged with a layer values of +/- 1 either accidentally or deliberately to hide inconvenient JOSM validator and Keepright warnings

RicoZ (talk) 13:41, 15 March 2014 (UTC)

I'd suggest giving no special meaning to layer values, so for me the warning should be issued for any layer value. It may be hard to arrive at a threshold everyone agrees with, probably setting it higher (say, 10 km) will result in fewer objections among mappers in various countries.--Fernando Trebien (talk) 16:36, 15 March 2014 (UTC)
In theory all layer values should be equal but in practice I think it makes sense to have the larger values reserved for bridges spanning huge valleys and some values for things that are very deep bellow the city like underground railway networks which are bellow all usual crossings and pedestrian passages. Checking every possible place where an extended underground railway could otherwise collide with a cellar or something else would be impractical. Also, layer=0 is special already.
I think 10 km is too much, it should be small enough that >50% of users editing the are will have the whole affected area downloaded. In urban areas people will often download much smaller areas, even substantially smaller than 1x1km2. Keepright will download even smaller areas.. typically it looks like 50x50m2 or maybe double the size. RicoZ (talk) 18:49, 15 March 2014 (UTC)

Current page abstract

I think that the current page abstract is much less clearly summarizing the most important points about the layer=* tag than the one from this page version was. In my opinion the current abstract is too verbose and also too hard to understand, especially for new users. Any precise tagging details should be covered within the page text itself and not within the introductory abstract.

I'd like to hear some opinions about that. Personally, I'd revert the abstract to the old version. Emkey08 (talk) 14:03, 15 April 2014 (UTC)

Please use the mailing archives, we have had lengthy discussions there about most of the issues quite recently where I asked on opinions about the current version. The version you suggest is incorrect (confuses level and layer in some places), very vague in many aspects and the definition of layer=0 as ground level is not generally accepted, the description of "ground level as it would be shown by contour lines on a topographic map" is highly problematic in urban areas. Also you would revert many important improvements.
Also, this is not meant to be a page for new users. New users should read the howto pages and specific pages about bridges, tunnels etc which do explain how to use layer for simple bridges and tunnels. RicoZ (talk) 14:55, 15 April 2014 (UTC)
Well, you're right about what this page is meant to be RicoZ, but the problem is this wiki page got conflicting informations with the page about tunnels (I don't know about bridges).
About crossing ways, on this page we got "Do not use layer=-1 to hide warnings about crossing or overlapping ways. Either fix them properly or leave the easily visible warning so that others can fix them.", but on the tunnel tag page, we got : "Most tunnels should be tagged with layer=-1 or another suitable value.". So, what a new user of OpenStreetMap (as me) should do when he gets a warning about crossing ways? Does he got to follow the layer tag page or the tunnel tag page? How is him supposed to know?
Beside that, JOSM gives a warning for either tag tunnel=yes and tunnel=building_passage for "crossing buildings". From what I know, This problem can only be solved by adding the layer=-1 tag. A tag that is discouraged by this wiki page... --IamSylve (talk) 22:09, 22 August 2014 (UTC)
Layer=-1 is not discouraged in this page, it is perfectly valid for tunnels and in more exotic cases for other objects. If that is the misunderstanding I can see if it can be stated somehow better. What is discouraged is another practice: the validator often shows dozens of warnings for crossing roads and rivers - the valid fix would be to add bridges or tunnels/culverts as appropriate but some editors instead add layer=-1 to the whole river to make the warnings disappear.
Can you point to a specific object that you are trying to edit or fix? I think it will be a lot easier to understand and explain when looking at a specific objects. Look at your editing history, (eg mine is ), click the edit where you changed the object, and it should show a list to all objects that you have changed - copy the link of the changed object. If you haven't edited it yet be bold and add an fixme=problem to the object. We also have various forums and mailing lists for beginners. RicoZ (talk) 08:27, 23 August 2014 (UTC)
Ok I understand now. Thanks for you answer, and sorry if it isn't the best place to discuss about this kind of problem. In fact, the fault was mine. I can't give you a link, because I already edited, but I took some screenshots.
In fact, I only got a warning when I didn't put nodes on the building, like on this screenshot : [1]. But when I followed this advice [2] and when I put nodes on the building [3], there was no more error about crossing buildings.
So well, sorry if I was and if I am off topic, and thanks for your answer, which helped me to understand things. --IamSylve (talk) 22:33, 23 August 2014 (UTC)
Ok, I found the object in question:
It is now correctly tagged. tunnel=building_passage is an exception to the rule and in most cases should not have a layer tag. Similar possibilities are covered=building_passage, here the path is not simply passing through the building but has some connection to it (shopping passage etc).
While looking at Geneve I noticed that very many tunnels there lack a layer tag. Many of those should be tunnel=building_passage, other should have the layer tag. Wondering if there is a problem in the French documentation somewhere and where to mention it? RicoZ (talk) 10:43, 24 August 2014 (UTC)
It may be a problem with the semi-auto import from the french cadastre (see FR:JOSM/Fr:Plugin/Cadastre-fr, WikiProject France/Cadastre/Import semi-automatique des bâtiments and ). However, I don't know where it may be mentionned, I'm not used to use it. Maybe I could ask on french OSM forums or mailing-lists. --IamSylve (talk) 14:22, 25 August 2014 (UTC)
I have contacted one user who has edited those and it is just an leftover from old times when some tagging possibilities like tunnel=building_passage were not available. RicoZ (talk) 21:19, 25 August 2014 (UTC)

"Because of many layer errors in the OSM database"

[4] "Because of many layer errors in the OSM database (both missing and grossly incorrect values) renderers give the layer tag the least weight of all considerations when determining drawing order and thus which feature is drawn above others." - what is source of this claim? Mateusz Konieczny (talk) 13:28, 6 September 2015 (UTC)

mailing lists, experience and observation.
Is it experience in editing OSM or is it experience in developing renderers? Maybe layer tags are frequently poor but it does not mean that it is primary reason for disregarding them. At least in case of Default map style more important reason was that sorting by layer would strongly encourage tagging for renderer. In addition, at least in case of styles using CartoCSS ordering everything primarily by layer would be at least irritating to implement. In general - is it something that data consumers explicitly mentioned as reason for giving low priority for layer tags or is it a guess? Mateusz Konieczny (talk) 14:03, 6 September 2015 (UTC)
what was wrong with the sentence "Recently mapnik changed its rule in that water areas are considered equal drawing priority to landuse/natural areas so that for example lakes overlapping landuse=forest are drawn with trees inside the water area" ??RicoZ (talk) 13:32, 6 September 2015 (UTC)
It is no related to layer tag. In theory there may be a water area tagged as hovering above forest (with layer tag on water higher than layer tag on forest). Some renderers may in this situation consider layer tag and display forest below water area. But both before and after layer tag was ignored on landcover. Mateusz Konieczny (talk) 13:50, 6 September 2015 (UTC)
The sentence may not have been related to the layer tag, but it is relevant for the sketch of a possible rendering order outlined there. While I would not want to go into too much detail of the rendering I believe there is a valid public interest to know how those things work.
I recall the wrong layer tags were explicitly mentioned as one of or the main reasons why "key:layer" gets a low priority in rendering but can not find the email message now and it has been long enough ago that my memory may not be entirely precise. RicoZ (talk) 15:27, 6 September 2015 (UTC)

I tried to describe it more precisely, as a result I think both the example with with waterways and the remark regarding the top-down view are no longer needed. RicoZ (talk) 13:46, 15 September 2015 (UTC)

I don't agree with this edit, the example is not particularly well chosen. layer=-1 for waterways (or any other features) does not mean that the waterway is underground because the layer tag is meaningful only in combination with tags like tunnel. The layer in that example is not incorrect, just not applicable. Hence the correct way to avoid this kind of modeling error seems to be to ignore layer tags not used in a well known combination such as bridge, tunnel. This is not a matter of rendering priority but correctness of the renderer. RicoZ (talk) 16:21, 16 September 2015 (UTC)

What is a top-down view?

Not quite sure what this means. RicoZ (talk) 21:25, 7 September 2015 (UTC)

What I meant was: Renderers do often not render things ordered from top to bottom (i.e. how you would see things when looking at them from above), but ordered by some kind of priority. A road might be drawn above a building, even though the building overlaps the road in real life. So if you want a reality-based ordering of features, you need a different approach. The content of that section is therefore not some universal rule (and should not inform tagging), but application-specific. Perhaps this could be worded better... --Tordanik 10:56, 8 September 2015 (UTC)
I see, made the mistake to mix geometric modeling, relevance filtering and visual rendering into one sketch of an algorithm. Will try to fix that. RicoZ (talk) 12:46, 8 September 2015 (UTC)

What to do with building=roof?

Discussion over at Key:covered, please comment there.--Jojo4u (talk) 21:24, 3 October 2015 (UTC)

Has been answered on that page but it belongs here for a principal reason: layer=* was only ever really well defined for crossings of linear ways. It never worked for points and the only kind of area so far where it made sense was man_made=bridge which can be considered a natural extension of this.
building=roof might be a nice to have exception but given the history that it was previously only well defined for crossings and linear ways it might not be a bad idea to stick with a much more restricted definition of layer instead of giving singular exceptions to random building types.
Restricted definition means easier and more powerful automated error checking. RicoZ (talk) 22:49, 3 October 2015 (UTC)

Suggestion:a road meeting different layer road at a junction should terminate early.

In Key:bridge page,it's suggested that a bridge meeting a non-bridge at a junction terminate early.Search "Showing a bridge incorrectly meeting " in I think this rule apply to layer.

Normally there should be a bridge or tunnel in this situation and the segment tagged with layer should be identical to that tagged as bridge/tunnel. "layer" without any of bridge, tunnel and a few other tags explicitly listed is in the page is discouraged. So in most cases that is what you are suggesting anyway. The wiki also strongly encourages to tag the shortest practical segments of ways with layer.
In principle the "layer" is only meaningful where two ways with different layer cross (without having a shared node), so it is not necessary to shorten it "artificially" by inserting extra nodes and way segments. Unlike a bridge a layer on itself does not represent any physical object or properties of any dimensions so it is not an error making the segment longer than strictly necessary. However it would be an error (or at least discouraged) to use "layer" without "bridge" or similar which is the practical limit here. RicoZ (talk) 11:25, 1 November 2015 (UTC)

Is there any valid use on relation, except multipolygons?

Is there any valid use of layer=* on relations, except mutipolygons? may be used to hunt for them. I ask as I want to fill onRelation field in the infobox Mateusz Konieczny (talk) 09:02, 18 February 2021 (UTC)