# Talk:Key:layer

## Message in red, is it about workarounds?

"Do not use this tag to correct some render behaviour and let the output look better.". If someone does it, is that what is called a "workaround"? Logictheo 10:25, 29 August 2008 (UTC)

Yes, e.g. drawing a park inside a lake and making it layer=1 just to have it drawn on the map. In that example the correct way would be to cut a hole in the lake with a multipolygon relation. Alv 10:39, 12 September 2008 (UTC)

## Layer

bridge=yes tells us: one thing (street, river) is upper than something tunnel=yes tells us: one thing (street, river) is under than something

Therefore we dont use a "layer"-attribute.

In layer we can read the OSM-Mantra: Do not use this tag to correct some render behaviour and let the output look better.

Bridge with layer=+1 is like animal=white horse+color=white...

--Markus 11:39, 3 September 2008 (UTC)

A tunnel does not go under something, it goes through something. Through the underground, through a hill, through a mountain or even a building. You should not use tunnel to mark a road going underneath a bridge.
A bridge goes over something. Over a field, river, road, an other bridge. The layer tag just tells the render engine to render the lowest layer first and the highest layer last.
--Skratz 14:01, 1 October 2008 (UTC)
No need to repeat that at so many locations, you don't want to have a discussion at different places at the same time, since that's impossible to follow up.
Now, your bridge with layer=1 is more like fruit=banana + color=yellow. Sure, most bananas are yellow, but you can also find them in green or brown, and if someone painted them, in red or purple. Likewise, bridges aren't always at layer 1 either, and tunnels aren't always at layer -1, so that's why we need this tag, since a bridge can well be at layer 0 in some cases, and we then need to enter in the data that road X is higher than road Y, and we've always used layer tags for that.
Also, the mantra you're citing is about doing some tricks with areas for example, where some people add a piece of natural=land in a natural=wood to have a place in the middle of the wood where there are no trees. That line has nothing to do with bridges or tunnels, because layer is giving physical properties of the real-life situation in those cases. --Eimai 12:36, 3 September 2008 (UTC)
For complex motorway junctions, bridges may themselves be bridged. In other circumstances, tunnels may themselves be tunneled under. So bridges can be layer +1, +2, etc. A bridge may go over something which has layer -1, so the bridge would be layer 0 etc. etc. Richard B 12:40, 3 September 2008 (UTC)
Yes Richard, for complex motorway junctions, the layer-concept may help.
But for a normal bridge or tunnel it's nativ how it works:
Bridge is upper
Tunnel is under
For normal cases (>95%?) we dont use a layer-attribut.
Yes Eimai, we have bridges starting on the floor, going up crossing something, and down to the floor. And bridges who connect "floor" to "floor", crossing a valley. And bridges going from a lower "floor" to a higher "floor". - What is in this cases the zero-level?
But we dont need a relativ attribute: each bridge is upper, and crosse something who is under.
In Switzerland there are tunnels like a screw: starting on a lower "floor" and screwing to an upper "floor"...
Yes, I know brown bananas - but (moast) tunnels will be under the bridge, and (moast) bridges will be over the tunnel.
So please lets cancel the "automatic layer"-attribute in connection with bridge or tunnel.
Thanks, --Markus 13:57, 3 September 2008 (UTC)
I don't really understand your problem. Read "layer=1" as "this thing is above anything with layer 0 or lower (and remember that by default everything has layer 0). If your bridge connects two sides over a valley then it's usually just layer 1, except when in that valley you have extra features that have layer 1.
I guess the thing you're proposing here is to automatically assume layer=1 for bridges and layer=-1 for tunnels? That makes sence IMHO. But don't start saying the layer tag is useless, it's obviously not.
For now, there's nothing assuming bridges are layer=1 by default (there are some tricks in mapnik renderers though I think), so telling here that you don't have to use a layer tag on bridges and tunnels isn't exactly how things work. You'll need some discussion on this and some sort of approval first. --Eimai 14:35, 3 September 2008 (UTC)

What kind of approuval do you look for?

Discussion: "Bridge and +1" is a pleonasm, also "tunnel and -1". It makes redundances. We dont need it.

--Markus 17:56, 3 September 2008 (UTC)

Approval means that mappers and renderers start applying the rule. And it's not a pleonasm, as said above several times, a bridge does not imply layer=1. It's layer=1 in most cases, but not all. --Eimai 18:31, 3 September 2008 (UTC)
I totally agree. I think bridges and tunnels are quite fundamental map features and usage recommendations regarding them should be considered more carefully. However, the implied values for those tags have not been subject to voting - or even proper discussion. Isn't it bit too early to actually document these kinds of things? Shouldn't this suggestion be placed under post-vote clean-up chapter on Proposed features page first?
These sort of unapproved radical changes make it unnecessarily hard to create translations. Personally, I hesitate translating them at all. Lazzko 14:02, 12 September 2008 (UTC)

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

### Examples

In my small region I have about 100 bridges which are 100% "layer 1" (100% pleonasm). And all tunnels are "layer -1" (100% pleonasm). So please, can you show me some examples with a normal bridge who is not "layer 1"? Thanks, --Markus 21:37, 3 September 2008 (UTC)

I don't know your requirement for a bridge to be normal, but there are plenty of bridges which aren't layer 1, see [1], [2], both near where I live, or go to [3] and have some layer fun :-) --Eimai 10:48, 4 September 2008 (UTC)
It's hardly a big issue to have a few objects tagged in this way. Just remember also how the renderer works. Objects in layer -5 are drawn first. Then objects in layer -4 are drawn on top. Then objects in layer -3 etc. Finally objects in layer +5 are drawn last. That has got to be simpler than requiring the renderers to have filters based on defaults for some objects, and still requiring layer tags for more complicated examples. Remember that bridges might be tagged bridge=yes, bridge=true, or even ones that specify what type of bridge it is, bridge=swing etc.
For what it's worth, data for the UK shows (on ways tagged bridge=yes and bridge=true);
• 2 bridges with layer=-2 (0.0%)
• 59 bridges with layer=-1 (0.4%)
• 22 bridges with layer=0 (0.2%)
• 12813 bridges with layer=1 (91.7%)
• 896 bridges with layer=2 (6.4%)
• 126 bridges with layer=3 (0.9%)
• 43 bridges with layer=4 (0.3%)
• 9 bridges with layer=5 (0.1%)
So nearly 10% of all bridges are tagged in a different layer than 1. Tagging something with a layer tag can only be redundant if one implies the other. It clearly does not. Looking at the stats for tunnels in European tagging suggests there are tunnels tagged between layer=3 and layer=-6. Richard B 11:36, 4 September 2008 (UTC)

Hi Eimai, thanks for your nice example. Its famous to see the result of nice rendering! It es a very good example for the exeptions when "layer" is necessary.

But moastly we dont need it. In your example 1: in this zoomlevel there is one crossing three lines together. In the next zoomlevel, there are 8 normal bridges which dont need any supplement keys. In Antwerpen, your example is the only case, who needs a layer. All other bridges (hundreds?) dont need a supplement key. Therefore I vote for canceling this unnecessary pleonasm for all normal bridges and tunnels.

Hi Richard, I'm not a statistician, but I think, before calculating we should check the probe. I suppose, in some of this cases we dont need a supplement key. And a "bridge-0/-1/-2" means something like "tunnel"? Also I'm astonished about bridge+5, do you now a source? Regardless, we can see that we dont need this pleonasm in moast cases. Every bridge implies that she is crossing over. And the renderer (if he has a little bit of intelligence) nows this (and we nows: "not tagging for the renderers"). So much more than 90% of the layer-tags are used redundant.

--Markus 17:10, 4 September 2008 (UTC)

Hmm, bridge -1 & -2 is *not* equal to tunnel. It means simply that it is above an object which has been tagged as layer -2 and -3 respectively. Layer 0 is not necessarily ground level. It all depends on what else might be there and tagged. The data has come from "Tagwatch" - you can see that from a link on the right-hand side on any wiki page about a tag or key. By not tagging for the renderer, we really mean; "don't introduce tagging which is incorrect, just to improve the output of the renderer" - e.g. don't tag things which don't have a vertical separation with layer tags just to improve the output. Whilst we could definitely improve on the renderers - I believe in this case that the current solution is simpler than the proposed solution. Richard B 22:14, 4 September 2008 (UTC)
In my understaning a pleonasm sounds wrong. So we should not use such doubling "to improve the output of some renderers"... As you says... --Markus 23:26, 4 September 2008 (UTC)
It's not animal=white horse+color=white, but animal=horse + horse=andalusian + color=white. Sure, most Andalusian horses are white but being white is unrelated to being Andalusian. Alv 10:43, 12 September 2008 (UTC)
Alv, with your example, you will say: you know simple bridges going under something? In my region all briges goes over something. So "bridge and layer+1" is a pleonasm, we dont need it for normal bridges. (like we dont need for rivers "water=yes" in moast cases). --Markus 18:32, 17 September 2008 (UTC)
If you're going to argument like that... All municipalities in my region belong to the country of Belgium. I therefore now claim that place=city/town/village + is_in=Belgium is a pleonasm. Hence place=city/town/village is sufficient and they should imply is_in=Belgium.
Silly idea? Yes, but you're proposing the same kind of thing.
I have no idea what you have against the layer tag. You're rallying against a tag that was well established at the early beginnings of OSM. --Eimai 19:08, 17 September 2008 (UTC)
Not under, but I do know a bridge on ground level. A motorway was built over a not-so-wet swamp and they decided to build a 470 meter long bridge but keep it real low and then piled some earth on the sides to seal the underside - there's no way under it, even for mice. That bridge was finished in 1970. It's not on osm map, because it's not evident from the landscape, at least not from the motorway and local mappers haven't found it yet. You seem to concentrate on the "not for renderers" clause, but layer information can be useful for other and any uses of osm data. It's not layer=+1 but layer=1, i.e. it's not the relative position ("this is over something") but locally absolute ("this object A is over objects B to E, except object C which is on layer=2") Alv 20:38, 17 September 2008 (UTC)
Hi Eimail, I have nothing against the layer tag. I'm agains useing it in a unnecessaty way as a pleonasm. "We have done it since a long long time" is not a valid argument. "Is-in" I did not now until yet - but it is also unnecessary: the fact is given by the boundary of your county. All included locations are "in". This is a hierachical relation. Layer may be useful for to tag floors in a building? But also here: we have to decide, floor=1 or layer=1 (and not floor=1+layer=1). --Markus 21:45, 17 September 2008 (UTC)
Well, let's not get distracted too much by the is_in tag (I agree it's a bad tag), but nevertheless, look at what you've written: it's unnecessary because you can make a boundary telling that every place in that boundary "is_in=country X". That would be like having a boundary around all bridges with layer=1 telling all bridges inside that boundary have layer=1.
And why do you keep calling it a pleonasm? Repeating it so often won't make it one. We've given enough explanation above why it is not a pleonasm. It might be in a small area where you live, but it's certainly not outside that area. --Eimai 11:58, 18 September 2008 (UTC)
Hi Alv, your 470m-bridge dont need al layer. A bridge is in all (normal) cases over the swamp (if there is not a flood or the piles broken). It does not matter, if the bridge is height=1 or height=100. --Markus 21:45, 17 September 2008 (UTC)

Hi Eimai, its not a good style to delete changes for the better against or without discussion:

Layer we need as raparation for missing altitude in cases of complex constructions (more than one bridge or tunnel). We need layers only for very local situations (never for the general z-dimension).

We do not need layers for areas like forest, water, not for normal (single) bridges, not for normal (single) tunnels. --Markus 15:31, 9 December 2008 (UTC)

So is everything on this page not a discussion then? The reason why I reverted is quite clear: the current practice is to tag every bridge and tunnel with a layer tag. You're trying to modify that so you should come up with a discussion first before changing it. --Eimai 15:40, 9 December 2008 (UTC)

The page does say very clearly that layer=* is not just there to make things render nicely. While it's not strictly necessary to tag everything this way, people do frequently tag it, therefore we should document it as such. It's certainly possible to have e.g. a railway running through a deep cutting (layer -1) over a bridge across a river, with a road bridge above it. You can't assume that something that is on a bridge is above all other features. Chriscf 09:35, 10 December 2008 (UTC)

Hi Chris, your example is good for layer. For "railway crossing street crossing river" we need layer (until we get altitude). We need layer in every case with more then one bridges and/or tunnels. But for normal single bridge we don't need layer.
Since a long time, the Wiki tells wrong things about layer. So all the people does it wrong. But doing wrong things, it's not a license for doing more wrong things, or for telling to others to do the same wrong things. --Markus 14:24, 10 December 2008 (UTC)
Where do you get this idea that specifying a layer value is somehow wrong? While we're at it, where do you get this idea about what constitutes a "bridge" and a "tunnel"? Chriscf 15:17, 10 December 2008 (UTC)
Adding layers for crossing and touching objects with vertical separation (regardless of whether either is a tagged as a bridge) seems to have been a original decision back in September 2006 (the oldest references to it that I could find in the mailing list archives) and documented as such in this wiki since early 2007. I think it's just good practice to keep it as such, or make a proposal to change it and convince all the notable old wizards for changes affecting such initial and long lived decisions. Alv 15:47, 10 December 2008 (UTC)

## Layer vs. Height

The layer-concept is not valide, because the relation is not clear.

Much more better will be to add the x/y-coordinate with the geographical hight.

```→ x/y/z-coordinate
```

--Markus 11:39, 3 September 2008 (UTC)

Since we generally lack the data that tells us at what altitude certain places are (and gps devices showing very inaccurate readings on that anyway -- or gps signals are inaccessible in tunnels for example), we replaced the z-coordinate with our simplified version called "layer". I don't see anything wrong with this. If you like to add height at every node, be my guest, but let's keep the bridges and tunnels situation simple for now and keep the layer for them. --Eimai 12:27, 3 September 2008 (UTC)
It is not possible to "replace" altitude by a local relative codeing like "layer".
It is not possible to map a larger area by "layer".
"Layer" like this is only useful as help-construction for complex under/over/under situations like Tokio-railstation or gaz/water/canalisation/electric-supply in big cities.
I think, "layer" was written for to help to the renderers, if they was not feeded by roules.
We should use the z-coordinate! Moast bridges and tunnels have a written alttitude at (start, middle, end). We can map it like a traffic sign. If there is no sign, we may ask in the gouverment.
--Markus 13:29, 3 September 2008 (UTC)
Let's just say the two can complement each other. You can't tell the height from the layer, and you can't tell the layer from height except when you have nodes every few meters on each way giving the accurate altitude. It may happen one day that we have that altitude data, but for now technology and resources just aren't available to do this. --Eimai 14:07, 3 September 2008 (UTC)

Until we will get the x/y/z-coordinate, we should do it like this:

```bridge=yes
```

or

```bridge=yes
+ altitude=###
```

or - in very complex situations:

```bridge=yes
+ altitude=###
+ layer=+3
```

Then the applications (renderer, routing, etc.) can do their best! --Markus 14:17, 3 September 2008 (UTC)

Most applications do not need to know altitude, but they may need to know whether things are above or below other things. For instance, a routing engine tracking you over a bi-level bridge will need to know that to go in the direction you want to go, you will be driving on the lower deck on layer 1, not the upper deck on layer 2. The fact that the lower deck is 15m above ground is neither here nor there. The simple implication "a bridge is above something" is no good when you are mapping a four-level stack, in which three sets of bridges cross over a single point. It is also no good when mapping London Underground, where Bank/Monument and King's Cross/St. Pancras each have lines running on four levels, all underground. The idea that bridge must have a layer>=0 and a tunnel must have layer<=0 makes sense; that these values must be +1 or -1 does not. Chriscf 15:52, 1 October 2008 (UTC)

Altitude we need for acclivity (biker, car with trailer).

Layer we need as raparation for missing altitude in cases of complex constructions (more than one Bridge or tunnel). --Markus 15:31, 9 December 2008 (UTC)

## 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)

## Rendering Areas and Labels

This is probably mostly an Osmarender issue...

Renderers should ignore the layer key (or, more specifically, don't assume a default "layer=0") for things like landuse/natural areas and motorway junction labels, right? Well, Osmarender doesn't. If there's a tunnel (or other such below-grade item) marked with "layer=-1" inside an area such as "landuse=industrial", that tunnel won't be visible in Osmarender. Also, I've noticed that labels for motorway junctions are rendered as if they are at "layer=0" even if the ways making up the motorway and its links are at some higher level; therefore, the label is drawn behind the road lines.

Solution: Render all "background coloring" type elements as if they are "layer=-infinity", and render all "label" type elements as if they are "layer=+infinity". In the case of using XSLT, this probably is as simple as moving some things to the beginning or end of the template. (I've read a bit about XSLT, but I'm not an expert...)

The alternative is to apply layer tags to these things. But doing so for landuse or natural areas would go against the big rule about the layer key: "Do not use this tag to correct some render behaviour as in just to make the output look better. This tag should only be used for height differences that are real." Adding layer tags to motorway junction nodes sort of makes sense because you're recording the relative height of something real, but what if an exit branches off of a motorway at a point that's under a higher bridge? It's clearly best to have the label appear on the map in front of everything, regardless of what layer the feature itself is on. Vid the Kid 23:08, 13 April 2009 (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 http://wiki.openstreetmap.org/wiki/IT_talk:Key:waterway#Key:layer 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.

Rationale:

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 http://www.openstreetmap.org/user/RicoZ/history ), 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 : [4]. But when I followed this advice [5] and when I put nodes on the building [6], 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: http://www.openstreetmap.org/way/299747695
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 http://www.cadastre.gouv.fr/ ). 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"

[7] "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 https://github.com/gravitystorm/openstreetmap-carto/pull/1728 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)

## Things to avoid

I propose to remove "Adding a layer results in ways at ground level getting hidden" - just because some renderer is poorly written is not a valid reason to map differently. Valid reason is that generally landuse is not above highways and other features (except already noted "The exception to this rule is where a landuse is indeed above another landuse."). I propose to also remove "As an example, a road or a river which is tagged with layer=-1 may not be rendered when crossing a landuse=forest with an implicit layer=0 tag" (is it even happening in some real renderers?)

"Use the smallest suitable layer value. Simple bridges over a way at ground level should use layer=1, not layer=2." - is there any good reason for this rule? Mateusz Konieczny (talk) 14:21, 6 September 2015 (UTC)

landuse&layer - tweak it as you like but should be probably mentioned that it is nonsense with the exception.
waterway&layer=1 bellow landuse=forest: yes, a common trap for real renderers. Mapsforge suffers it unless data is prepossessed or hacks applied and a few online renderers that I have tried as well.
smallest layer value: convention and layer<=5. Not important but makes life easier for other mappers if people follow conventions. RicoZ (talk) 15:40, 6 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 https://wiki.openstreetmap.org/wiki/Key:bridge. 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)