Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Low-zoom coastline simplification and outline problems #3695

Closed
jeisenbe opened this issue Feb 24, 2019 · 37 comments
Closed

Low-zoom coastline simplification and outline problems #3695

jeisenbe opened this issue Feb 24, 2019 · 37 comments

Comments

@jeisenbe
Copy link
Collaborator

Current Situation

Since PR #3065 the land polygons have been simplified and outlined at z0 to z7. Previously, the land polygons were shown without an outline and without any simplification.

The simplified land polygon shapefiles are used, which have nearly full detail for all land features at z9 and below, but Mapnik's line-simplify option is used to somewhat smooth out the coastline, and then a sub-pixel-width outline is added.

The 0.5 pixel outline is currently offset 0.5 pixels from the coast, which leads to some errors when exporting at higher resolution, when the coastline is particularly curvy. There is also a mismatch between small islands and the outline; some small islands are shown but do not have a visible outline.

When exported at 2x or higher resolution, these problems are even more apparent.

Options for resolving the issue

  1. Revert Give oceans outline and simplify shapefiles on z0-7 #3065 - remove simplification of the water polygons and the outlines

  2. Switch to generalized coastline shapefiles for the outline and generalized water polygons for the z0 to z7 land / oceans

  • This would allow rendering the coastline outline, but will have more consistent results and will also work when exporting at higher resolutions

Links and screenshots illustrating the problem

Current rendering of Greece, screenshot:
https://www.openstreetmap.org/#map=5/38.065/24.038
z5-greece-screenshot

Land polygons only, current master branch:
z5-greece-master-missing-islands

Zoomed in; missing island outlines are apparent
z5-greece-missing-islands-zoomin

Exported at 2x from kosmtik:
master-export2x-greece

Exported at 5x from kosmtik:
master-export5x-greece

(Compared to rendering with generalized coastline shapefiles)
z5-export2x-greece-generalized-coastlines-1zlate

@jeisenbe
Copy link
Collaborator Author

jeisenbe commented Mar 5, 2019

Is everyone happy with the simple solution of removing the outline and simplification in PR #3694 - or should I show some more examples of rendering with the generalized coastlines at z0 to z7?

@jeisenbe
Copy link
Collaborator Author

jeisenbe commented Mar 5, 2019

The outline also over-emphasizes tidal channels in mangroves and saltwater marshes, and river mouths, eg:

z7 Timika current rendering
https://www.openstreetmap.org/#map=7/-4.861/137.252
z7-timika-current

Without coast outline
z7-timika-after

@matkoniecz
Copy link
Contributor

I admit that in places with irregular coast (Timika, small islands) dropping border works well but in other places losing border makes map worse.

I am not sure what is preferable.

@imagico
Copy link
Collaborator

imagico commented Mar 5, 2019

The question that arises is what the goal of #3065 is. I consider it highly problematic in terms of mapper feedback (both due to the errors shown here and due to other issues it is very hard for mappers to understand how the appearance in the map relates to how things are mapped without an in depth knowledge how things are rendered). And i also don't think it really serves as a usable example for other map styles because of inherent flaws in the method used and since parameters have been tuned to work around the various problems (like the 180 degree meridian artefacts, small islands, the wrong drawing order).

Independent of the specific technical issues having a special rendering style for coastlines at z0-z7 but not above indicates a specific low zoom design idea for the map. But so far i don't see this. Most map styles that draw coastlines or waterbody outlines in general with a line do so at large scales, not at small scales.

@jragusa
Copy link
Contributor

jragusa commented Mar 5, 2019

Timika is probably not a good example : mappers extended coastline (https://www.openstreetmap.org/relation/8661308#map=13/-5.0509/137.4330) along rivers (https://www.openstreetmap.org/relation/8504221) which explains the weird pattern

@jeisenbe
Copy link
Collaborator Author

jeisenbe commented Mar 7, 2019 via email

@Adamant36
Copy link
Contributor

Timika is probably not a good example : mappers extended coastline (https://www.openstreetmap.org/relation/8661308#map=13/-5.0509/137.4330) along rivers (https://www.openstreetmap.org/relation/8504221) which explains the weird pattern

That happened to some places that I map where people extended the river area miles up streams. It was rather irritating. I think the blue outline would be good in cases where the coastline is mostly straight, but not in most of the examples here. Is there a way it can be toned down enough to not stand out as much or make it only apply to semi-straight coastlines (that would probably look inconsistent)?

@imagico
Copy link
Collaborator

imagico commented Mar 7, 2019

Most of those are not rivers but tidal channels in mangroves. They are filled with salt water and the flow changes direction with the tide.

Indeed. Coastline placement in the OSM database is and should be a matter of local observable properties, not of what is considered cartographically desirable for a specific styling idea at a specific map scale. This style should incentivize the former, not the latter. A styling concept that emphasizes the significance of the coastline at low zooms but de-emphasizes it at high zooms does not really support this however.

The discussion here IMO should focus on the cartographic merits of #3065 w.r.t. to the goals we have. It would be good to get the input from those who originally discussed this change (@matthijsmelissen, @kocio-pl and @pnorman). There is not much in the PR discussion beyond the expression of subjective like for the change.

@pnorman
Copy link
Collaborator

pnorman commented Mar 7, 2019

I'm in favour of removal as this issue has brought up places where it fails badly.

@matthijsmelissen
Copy link
Collaborator

The question that arises is what the goal of #3065 is.

The goal is to increase contrast between water and land, which makes the map easier to read, especially around complex coastlines.

With respect to the proposed revert, I'm fairly neutral.

@matthijsmelissen
Copy link
Collaborator

A general point: personally I am against optimizing for 2x exports at the cost of the 1x version as long as openstreetmap.org renders the 1x version.

@imagico
Copy link
Collaborator

imagico commented Mar 8, 2019

I don't think @jeisenbe showed the high resolution samples as a problem per se but to better illustrate problems observed at normal resolution.

If the aim is purely to increase contrast of the land-water boundary the line simplification does not appear to be useful. A dark halo around land areas on the water side is something that can work nicely without the distortion inherent to geometry modification steps.

@kocio-pl
Copy link
Collaborator

kocio-pl commented Mar 8, 2019

For me current rendering improves clarity. Less details together with better visible line at lower zoom levels works great in most of the cases. Timika etc. is visually worse (but still acceptable for me) and conceptually it's highlighting the special data situation there (we claim there are some kind of small ocean islands, not part of the land).

@imagico
Copy link
Collaborator

imagico commented Mar 8, 2019

@matthijsmelissen - what i still don't understand about #3065 is the reason why z0 to z7 and not above. Was this because of interference with landcover rendering (which back then started at z8)? That would mean #3458 was essentially incompatible to some extent with #3065. The effect is relatively subtle though (some additional non-uniformity in the line where landcover is mapped near the coast) and it probably is even more so at z8/z9 so it seems doubtful this played a role.

@matthijsmelissen
Copy link
Collaborator

matthijsmelissen commented Mar 8, 2019

what i still don't understand about #3065 is the reason why z0 to z7 and not above.

It's because I wanted to avoid blue lines crossing rivers at the place where rivers run into the sea. At z7 and lower this is not noticeable in most places because rivers at these zoom levels are very thin. From z8, some rivers start to become multiple pixels wide at the place they reach the sea, and the line diving rivers and sea would become noticeable.

Landuse has nothing to do with this.

@imagico
Copy link
Collaborator

imagico commented Mar 8, 2019

Ah, ok - thanks.

@jeisenbe
Copy link
Collaborator Author

jeisenbe commented Mar 12, 2019

It looks like @kocio-pl is still in favor of using generalization and outlines at low zoom, @matthijsmelissen and @matkoniecz are neutral, @imagico and @pnorman are opposed to the current rendering with outlines.

I would suggest merging #3694 for now, which will remove the current simplification and outlines.

The option that would provide and outline with better results would be to use the generalized coastlines from http://openstreetmapdata.com/data/generalized-coastlines - which conveniently are provided for z0 to z8. These still show some problems in areas with many tidal channels, but they do not have any issues with missing islands, and the generalization process as a very nice cartographic result. However, they are even more simplified/generalized than the current low-zoom outlines.

But we need to decide on this soon, if we want these shapefiles to stay available. See: https://blog.jochentopf.com/2019-03-07-the-new-osmdata-service.html

"We are currently not offering the Generalized coastlines, the Reduced waterbodies as raster mask and the Reduced waterbodies as polygons on the new service. We might bring them to the new service, but this depends on whether people actually need these. Please contact me if you currently use any of them."

Greece at z6 with generalized coastlines:
z5-export2x-greece-generalized-coastlines-1zlate

Compare to z6 rendering with simplified water polygons (i.e. with PR #3694)
z6-greece-ocean-simplified-water-polygons

And here's z7 Wales with generalized coastlines (and landcover colors simplified as in PR #3670)
z7-wales-4colors-generalized

Compare to z7 Wales with current coastline style (same landcover colors as #3670):
z7-wales-altcolors

z3 Indonesia with generalized coastline and outline:
z3-indonesia-generalized-outline

z3 Indonesia current style:
z3-indonesia-ocean-master

z3 Europe, generalized:
z3-europe-generalized-outline

z3 Europe, current style:
z3-ocean-master

z3 Europe, after #3694 (without outline):
z3-ocean-simplified-water-polygons

@jeisenbe
Copy link
Collaborator Author

jeisenbe commented Mar 12, 2019

Here are some more comparisons with generalized coastline shapefiles vs current rendering and outline-less rendering.

Papua, Indonesia (as mentioned in the comment above)
https://www.openstreetmap.org/#map=7/-4.861/137.252
z6 current master
z6-Papua-master
z7 current master
z7-timika-master

z6 without outline (after PR #3694)
z6-papua-after
z7 without outline (after PR #3694)
z7-timika-without-outline

z6 generalized coastline, thicker outline
z5-export2x-timika-generalized-1xlate

z6 less generalized (using shapefiles 1 zoom level lower than designed)
z6-timika-generalized-1zlate
z7 less generalized (using shapefiles 1 zoom level lower than designed)
z7-timika-generalized-1zlate

  • This last option looks more similar to the current rendering with outline and simplification, by using the generalized shapefiles one zoom level sooner than intended, as an example of using less generalization.

@jeisenbe
Copy link
Collaborator Author

Scotland, UK:
z7 current master
z7-scotland-master

z7 without outline (after PR #3694)
z7-scotland-water-polygons

z7 generalized coastline, thicker outline
z6-export2x-generalized-scotland-1zlate

z7 less generalized (using shapefiles 1 zoom level lower than designed)
z7-scotland-generalized-1zlate

@Adamant36
Copy link
Contributor

Its a trade off definitely. z6 without outline (after PR #3694) is harder to see without the outline. It's to bad water isn't a tag darker.

@imagico
Copy link
Collaborator

imagico commented Mar 12, 2019

Note moving further processes from openstreetmapdata.com to the new platform is not a matter of urgency, it is a matter of available time to actually do so. The generalized coastlines currently have the lowest priority in that regard.

One of the main advantages of the new platform is that different processes are more compartmentalized now so it is relatively easy for anyone to develop new processes within this framework and add them. Anyone is welcome to do so on https://github.com/fossgis/osmdata.

The other question is of course how much pre-processing of data is actually desirable. I am generally in favor of this where it is needed for constructive mapper feedback and a process exists to do so but i don't really think this style is a place to add complexity in pre-processing just for eye candy so to speak.

@jeisenbe
Copy link
Collaborator Author

Shikoku, Japan: current master
z5 before
z5-shikoku-master

z6 before
z6-shikoku-master

z7 before
z7-shikoku-master

After PR 3694 (no outline)
z5 no outline
z5-shikoku-ocean-polygons

z6 no outline
z6-shikoku-ocean-polygons

z7 no outline
z7-shikoku-ocean-polygons

Generalized coastlines - [1 zoom level late]
z5 generalized
z5-shikoku-generalized

z6 generalized
z6-shikoku-generalized

z7 generalized
z7-shikoku-generalized

@jeisenbe
Copy link
Collaborator Author

Estonia has an interesting coastline and very complete landcover mapping:

Current rendering:

z5
z5-estonia-master
z6
z6-estonia-master
z7
z7-estonia-master

Water polygons, no outline:

z5
z5-estonia-water-polygons
z6
z6-estonia-water-polygons
z7
z7-estonia-water-polygons

Generalized coastline:

z5
z5-estonia-generalized-original
z6
z6-estonia-generalized-original
z7
z7-estonia-generalized-original

Less generalized (by using generalized shapefiles 1 zoom level earlier)

z5
z5-estonia-generalized-less
z6
z6-estonia-generalized-less
z7
z7-estonia-generalized-less

@pnorman
Copy link
Collaborator

pnorman commented Mar 14, 2019

If we want to discuss generalized coastline that should be its own issue and we can then keep this confined to just the switch to ocean polygons.

@jeisenbe
Copy link
Collaborator Author

Now that #3694 is merged, we should decide if the outline is important enough to be worth the extra complexity and the dependence on external shapefiles. One objection to the current outlines is that they did not extend to lower zoom levels. This was because the line would look strange when cutting across rivers and estuaries.

However, this issue has a solution: if we change rivers to a darker color as planned, then the outline for marine waters can be the same color as the new river color. This way, the marine water outline blends perfectly with the river water color.

Here are examples with the 3-color water system, using the generalized coastlines and shapefiles for < z8 and the simplified and split water polygons and coastline shapefiles for z9 and up:

Anchorage, Alaska z7 current
z7-anchorage-before
After: With 3 colors for water (lighter ocean, darker rivers) and marine water outline matching river color:
z7-anchorage-after

z8 current
z8-anchorage-before
z8 after
z8-anchorage-after

z9 current
z9-anchorage-before
z9 after
z9-anchorage-after

Bremen, Germany

  • This is an example where the coastline extends far up the river till the tidal section ends at a weir or dam, in the city of Bremen
    z11 before
    z11-bremen-before
    z11 after
    z11-bremen-after

z12 before
z12-bremen-before
z12 after
z12-bremen-after

z14 before
z14-weser-before
z14 after
z14-weser-bremen-after

@imagico
Copy link
Collaborator

imagico commented Mar 25, 2019

That does not seem a good idea because it would introduce a water bias and would give confusing feedback to mappers showing the ocean outline in a way that looks like a river geometry.

I would suggest to close this issue because the specific problems discussed here no more apply after #3694 and instead would open specific issues on problems we have and address them in the best way possible. But it would probably make sense to put priority on those things that have been waiting for the move to ocean polygons and layer-reordering.

One thing i hope this subject has shown to everyone is that you have to be careful making design choices that severely limit your options w.r.t. other changes and that maneuver the style into a position where you can't improve anything any more without sacrificing central goals or reverting previous choices made.

What i would like to see - and which kind of goes into a similar direction as your samples is an edge emphasized (in terms of color) rendering of oceans that does not introduce a land or water bias and that does work independently of geometry simplification. This is not trivial, it probably requires some comp-op magic similar to what @sommerluk developed for the unpaved roads. And i am not sure if the results would actually be desirable to have in this style. But it would definitely be something to try out.

@jeisenbe
Copy link
Collaborator Author

jeisenbe commented Mar 25, 2019

Zeeland, the Netherlands

  • Currently it's not easy to see where the coastline is placed in this area, below z7
    z7 zoomed in, current
    z7-zeeland-current-2x
    z7 after (with landcover and water color changes in addition)
    z7-zeeland-after-2x

z9 Zeeland current
z9-zeeland-before

z9 after
z9-zeeland-after

z10 current
z10-zeeland-before

z10 after
z10-zeeland-after

The position and width of the outline could be tweaked, but I'm just showing these images to give a general idea of what it might look like.

@jeisenbe
Copy link
Collaborator Author

jeisenbe commented Mar 25, 2019

it would introduce a water bias

Do you mean that it would cause narrow sections of coastline to appear wider than they are in reality, eg tidal channels, narrow bays? We do show narrow rivers and streams as wider than their actual sizes at these zoom levels.

... confusing feedback to mappers showing the ocean outline in a way that looks like a river geometry.

Yes, that is an issue

an edge emphasized (in terms of color) rendering of oceans that does not introduce a land or water bias

That would be great. It seems like having a gradient that gets lighter with increasing distance from the edge of the polygon would be a great way to render the marine environment; this is frequently seen on historic paper maps.

I couldn't find any documentation of this in Mapnik.

@imagico
Copy link
Collaborator

imagico commented Mar 25, 2019

Do you mean that it would cause narrow sections of coastline to appear wider than they are in reality, eg tidal channels, narrow bays? We do show narrow rivers and streams as wider than their actual sizes at these zoom levels.

I mean the outline drawing indicating the extent of the water area being larger than as it is mapped systematically decreasing the size of land and increasing the size of water in rendering. This is different from centerline drawing of waterways where the line signature is never meant to indicate the water covered area.

I couldn't find any documentation of this in Mapnik.

Mapnik has no native support for gradients, you'd have to approximate such with multiple lines in different colors.

@pnorman
Copy link
Collaborator

pnorman commented Mar 26, 2019

Mapnik has no native support for gradients, you'd have to approximate such with multiple lines in different colors.

I'd do it with MSS similar to how we do nature reserves, but no transparency.

@imagico
Copy link
Collaborator

imagico commented Mar 26, 2019

Yes, but nature reserves use line-offset and that would depend on unsplit polygons which would lead to the same constraints as we had with the outlines and line simplification.

@jeisenbe
Copy link
Collaborator Author

jeisenbe commented Mar 27, 2019

Yes, but nature reserves use line-offset and that would depend on unsplit polygons which would lead to the same constraints as we had with the outlines and line simplification.

We can use the coastline linestrings for the high zoom levels, but it would be ideal to have slightly generalized coastlines up to z9. Right now the generalized coastlines available on openstreetmapdata.com end at z8. It would be perfect to have a transitional level at z9, less generalized that the lower zoom levels. Then we would not need to use simplified-water-polygons-split.

Another option is to use the simplified-land-polygons-complete for the coastline outline, and the water polygons to render the water fill, at z9. That's what I did in the examples above, because I have not yet downloaded the coastline linestring shapefiles. But some comp-op sorcery would be necessary if it's essential that the outline not extend outside of the actual area of water, whichever shapefiles are used.

@jeisenbe
Copy link
Collaborator Author

jeisenbe commented Apr 4, 2019

I've tried several different pseudo-gradients by using line-offset and different line widths for each color, eg:

.coastline {
  [zoom >= 1] {
        c/line-width: 2.0;
        c/line-color: @water-color;
        c/line-offset: 1.0;
        b/line-width: 1.0;
        b/line-color: @river-color;
        b/line-offset: 0.5;

I haven't yet found the right comp-op option to get the rendering perfect, but I can show what it would like, ideally. It looks like we would need to double-up on shapefiles (using separate shapefiles for the water polygons and the coastline). Should I continue to work on this?

2 pixel wide gradient:
z5 Alaska 2px
z5-yukon-river-2pixel-gradient

z5 Great Lakes 2px
z5-great-lakes-2pixel

z6 Amazon 2px
z6-amazon-river-2pixel-gradient

z6 Greece 2px
z6-greece-2pixel-gradient

z13 Bremen 2px
z13-bremen-2pixel-gradient
z14
z14-bremen-weser-2pixel-gradient

1 pixel wide gradient (Half-pixel steps)
z3 Europe 1px
z3-europe-1pixel-gradient

z5 Alaska 1px
z5-yukon-river-1pixel-gradient

z5 Great Lakes 1px
z5-great-lakes-1px-gradient

z6 Amazon 1px
z6-amazon-1pixel-gradient

z6 Greece 1px
z6-greece-1pixel-gradient

z13 Bremen 1px
z13-bremen-1pixel-gradient
z14
z14-bremen-1pixel-gradient

(I also tried a 4 pixel wide gradient, but I don't think it looks good; small islands are over-emphasized)
z3 Europe 4px
z3-europe-ocean-gradient

z5 Alaska 4px
z5-yukon-river-gradient

@imagico
Copy link
Collaborator

imagico commented Apr 4, 2019

Yes, that goes in the direction i had in mind. But as said you can't use line-offset because the lines are split and this will result in artefacts at the splits: Either gaps or overlaps between the offset segments depending on if the coastline is concave of convex at this point. And you also get further distortion where the offset line drawing of one coastline geometry is drawn over another land feature.

Anyway - the logical next step to proceed with the coastlines is to do the layer re-ordering. Anything else like different coloring of different water features or this would come afterwards.

@pnorman
Copy link
Collaborator

pnorman commented Apr 4, 2019

Anyway - the logical next step to proceed with the coastlines is to do the layer re-ordering. Anything else like different coloring of different water features or this would come afterwards.

+1. There were other ideas we had for improvements after switching to water polygons.

@jeisenbe
Copy link
Collaborator Author

These are the gradients formed using dst-out and dst-over. I made them back on 5-April-2019 but had decided not to work on it further at the time. These tests also used different colors for rivers, lakes and ocean. As you see, it works:

z12-timika-rivers-dst-over

z6-amazon-2px-gradient-dst-over

z5-great-lakes-2px-dst-over

@jeisenbe
Copy link
Collaborator Author

jeisenbe commented Oct 9, 2019

This issue was solved by #3694 so I will open a new issue to discuss adding back an outline to the ocean polygons, which requires relayering and using comp-op as discussed in #3854

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants