Different hillshading approaches

View: New views
7 Messages — Rating Filter:   Alert me  

Different hillshading approaches

by Colin Marquardt-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi guys,

I just cannot live with the fact that "they" have awesome hillshading
in a slippy map and I cannot replicate it with Mapnik and OpenLayers:

http://www.mapy.cz/#x=132471808@y=138964992@z=12@mm=RTP

(that area nicely shows the tile overlays).

All *I* can manage with this kind of layering is
http://opentiles.com/cmarqu/relief.html?zoom=13&lat=50.9354&lon=14.20458&layers=BT
or
http://opentiles.com/cmarqu/relief_flipped.html?zoom=13&lat=50.9354&lon=14.20458&layers=BT
(layer order changed and opacities adapted.)

When you toggle their "Stínování" layer, the brightness and crispness
of the map doesn't change much, it just gets hillshading.  My map is
very foggy in comparison. It's most likely not the thinner/smaller
fonts in my map, since the "Bad Schandau" there is as bold and black
as possible, but still washed out in the map due to the opacity. Their
text somehow stays at 100% black.

The relief layer is different of course, but not so much IMO:
http://m4.mapserver.mapy.cz/relief-l/11_7e60000_8480000 vs.
http://opentiles.com/cmarqu/tiles_relief/12/2209/1372.png

Does anybody have a guess as to what the crucial difference is?

Doing the hillshading like this could have the advantage of a smaller
tile size overall, since you could reduce the number of colors needed
for the roads layer. With an all-in-one tile (roads and hillshading),
there are too many mixed colors which would get ugly banding if
color-reduced too much.

(FWIW, my all-in-one tiles are at
http://opentiles.com/cmarqu/?zoom=13&lat=50.92308&lon=14.16252, done
with the process that Marcin described a while ago.)

Cheers
  Colin
_______________________________________________
Mapnik-users mailing list
Mapnik-users@...
https://lists.berlios.de/mailman/listinfo/mapnik-users

Re: Different hillshading approaches

by Beau Gunderson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

FireBug tells me that your basemap opacity is at 0.7 while the
hillshade above it is at 0.99--and it also seems that in Firefox the
hillshade is on the bottom and that the basemap is on the top and you
are effectively viewing the hillshade through the basemap!

Was that the intent? I would assume that it would look best if the
basemap were on the bottom at opacity 1 and the hillshade above it had
opacity less than or equal to 1.


- Beau

On Tue, Jun 2, 2009 at 3:58 PM, Colin Marquardt <cmarqu42@...> wrote:

> Hi guys,
>
> I just cannot live with the fact that "they" have awesome hillshading
> in a slippy map and I cannot replicate it with Mapnik and OpenLayers:
>
> http://www.mapy.cz/#x=132471808@y=138964992@z=12@mm=RTP
>
> (that area nicely shows the tile overlays).
>
> All *I* can manage with this kind of layering is
> http://opentiles.com/cmarqu/relief.html?zoom=13&lat=50.9354&lon=14.20458&layers=BT
> or
> http://opentiles.com/cmarqu/relief_flipped.html?zoom=13&lat=50.9354&lon=14.20458&layers=BT
> (layer order changed and opacities adapted.)
>
> When you toggle their "Stínování" layer, the brightness and crispness
> of the map doesn't change much, it just gets hillshading.  My map is
> very foggy in comparison. It's most likely not the thinner/smaller
> fonts in my map, since the "Bad Schandau" there is as bold and black
> as possible, but still washed out in the map due to the opacity. Their
> text somehow stays at 100% black.
>
> The relief layer is different of course, but not so much IMO:
> http://m4.mapserver.mapy.cz/relief-l/11_7e60000_8480000 vs.
> http://opentiles.com/cmarqu/tiles_relief/12/2209/1372.png
>
> Does anybody have a guess as to what the crucial difference is?
>
> Doing the hillshading like this could have the advantage of a smaller
> tile size overall, since you could reduce the number of colors needed
> for the roads layer. With an all-in-one tile (roads and hillshading),
> there are too many mixed colors which would get ugly banding if
> color-reduced too much.
>
> (FWIW, my all-in-one tiles are at
> http://opentiles.com/cmarqu/?zoom=13&lat=50.92308&lon=14.16252, done
> with the process that Marcin described a while ago.)
>
> Cheers
>  Colin
> _______________________________________________
> Mapnik-users mailing list
> Mapnik-users@...
> https://lists.berlios.de/mailman/listinfo/mapnik-users
>
_______________________________________________
Mapnik-users mailing list
Mapnik-users@...
https://lists.berlios.de/mailman/listinfo/mapnik-users

Re: Different hillshading approaches

by Beau Gunderson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I also just verified that on Mapy.cz they are rendering both tiles at
opacity 1 with the basemap on the bottom and the hillshade on top.


- Beau

On Tue, Jun 2, 2009 at 4:55 PM, Beau Gunderson <beau@...> wrote:

> FireBug tells me that your basemap opacity is at 0.7 while the
> hillshade above it is at 0.99--and it also seems that in Firefox the
> hillshade is on the bottom and that the basemap is on the top and you
> are effectively viewing the hillshade through the basemap!
>
> Was that the intent? I would assume that it would look best if the
> basemap were on the bottom at opacity 1 and the hillshade above it had
> opacity less than or equal to 1.
>
>
> - Beau
>
> On Tue, Jun 2, 2009 at 3:58 PM, Colin Marquardt <cmarqu42@...> wrote:
>> Hi guys,
>>
>> I just cannot live with the fact that "they" have awesome hillshading
>> in a slippy map and I cannot replicate it with Mapnik and OpenLayers:
>>
>> http://www.mapy.cz/#x=132471808@y=138964992@z=12@mm=RTP
>>
>> (that area nicely shows the tile overlays).
>>
>> All *I* can manage with this kind of layering is
>> http://opentiles.com/cmarqu/relief.html?zoom=13&lat=50.9354&lon=14.20458&layers=BT
>> or
>> http://opentiles.com/cmarqu/relief_flipped.html?zoom=13&lat=50.9354&lon=14.20458&layers=BT
>> (layer order changed and opacities adapted.)
>>
>> When you toggle their "Stínování" layer, the brightness and crispness
>> of the map doesn't change much, it just gets hillshading.  My map is
>> very foggy in comparison. It's most likely not the thinner/smaller
>> fonts in my map, since the "Bad Schandau" there is as bold and black
>> as possible, but still washed out in the map due to the opacity. Their
>> text somehow stays at 100% black.
>>
>> The relief layer is different of course, but not so much IMO:
>> http://m4.mapserver.mapy.cz/relief-l/11_7e60000_8480000 vs.
>> http://opentiles.com/cmarqu/tiles_relief/12/2209/1372.png
>>
>> Does anybody have a guess as to what the crucial difference is?
>>
>> Doing the hillshading like this could have the advantage of a smaller
>> tile size overall, since you could reduce the number of colors needed
>> for the roads layer. With an all-in-one tile (roads and hillshading),
>> there are too many mixed colors which would get ugly banding if
>> color-reduced too much.
>>
>> (FWIW, my all-in-one tiles are at
>> http://opentiles.com/cmarqu/?zoom=13&lat=50.92308&lon=14.16252, done
>> with the process that Marcin described a while ago.)
>>
>> Cheers
>>  Colin
>> _______________________________________________
>> Mapnik-users mailing list
>> Mapnik-users@...
>> https://lists.berlios.de/mailman/listinfo/mapnik-users
>>
>
_______________________________________________
Mapnik-users mailing list
Mapnik-users@...
https://lists.berlios.de/mailman/listinfo/mapnik-users

Re: Different hillshading approaches

by Marcin Rudowski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Colin Marquardt pisze:
> The relief layer is different of course, but not so much IMO:
> http://m4.mapserver.mapy.cz/relief-l/11_7e60000_8480000 vs.
> http://opentiles.com/cmarqu/tiles_relief/12/2209/1372.png
>
> Does anybody have a guess as to what the crucial difference is?
>
They are more different then You think. In Your case You shade
luminosity and assign opacity 0.7 (constant alfa). In mapy.cz image is
all black and in fact shaded alfa channel is making it look relief.

Try to invert Your gray value and make it alfa of new black image.
Then simple composition with base layer without any additional opacity
change in OpenLayers should be enough.

Nice trick with multiplication by using www browser to apply alfa and
make it hillshaded.

I tried this too when experimenting, but finally decided for different
approach (like gimp's merge-grain):
http://mapa.ump.waw.pl/ump-www/?zoom=10&lat=49.54125&lon=19.28081
https://lists.berlios.de/pipermail/mapnik-users/2009-February/001651.html
On the other side, I have some areas too bright.

Comparison of different methods using Your image:
http://mapa.ump.waw.pl/ump-www/mapnik/composing.png

Legend:
without effect     opacity(Your example)
merge-grain(mine)  multiply(mapy.cz)


Marcin Rudowski
_______________________________________________
Mapnik-users mailing list
Mapnik-users@...
https://lists.berlios.de/mailman/listinfo/mapnik-users

Re: Different hillshading approaches

by Marcin Rudowski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Marcin Rudowski pisze:
> Comparison of different methods using Your image:
> http://mapa.ump.waw.pl/ump-www/mapnik/composing.png
>
> Legend:
> without effect     opacity(Your example)
> merge-grain(mine)  multiply(mapy.cz)

Same comparison with mapy.cz images:
http://mapa.ump.waw.pl/ump-www/mapnik/composing2.png
_______________________________________________
Mapnik-users mailing list
Mapnik-users@...
https://lists.berlios.de/mailman/listinfo/mapnik-users

Re: Different hillshading approaches

by Colin Marquardt-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/6/3 Marcin Rudowski <mrudowski1@...>:

> Colin Marquardt pisze:
>> The relief layer is different of course, but not so much IMO:
>> http://m4.mapserver.mapy.cz/relief-l/11_7e60000_8480000 vs.
>> http://opentiles.com/cmarqu/tiles_relief/12/2209/1372.png
>>
>> Does anybody have a guess as to what the crucial difference is?
>>
> They are more different then You think. In Your case You shade
> luminosity and assign opacity 0.7 (constant alfa). In mapy.cz image is
> all black and in fact shaded alfa channel is making it look relief.
>
> Try to invert Your gray value and make it alfa of new black image.
> Then simple composition with base layer without any additional opacity
> change in OpenLayers should be enough.

Wow, thanks very much for this. Now it's all clear...

Can your Mapnik work that went into 0.6 produce just such tiles? When
I use them to read the raster image created by hillshading.cpp from
demtools, they are much more nicely smoothed, and it would be great to
not have an additional step needed.

> I tried this too when experimenting, but finally decided for different
> approach (like gimp's merge-grain):
> http://mapa.ump.waw.pl/ump-www/?zoom=10&lat=49.54125&lon=19.28081
> https://lists.berlios.de/pipermail/mapnik-users/2009-February/001651.html

Yes, I'm basically following your process on my "main map". IMHO the
mapy.cz way looks a bit nicer, as it doesn't have the plastic-looking
effect so much and leaves the colors intact.

Do you think the separation of the tiles would help reducing colors
and total size of tiles needed?

> Comparison of different methods using Your image:
> http://mapa.ump.waw.pl/ump-www/mapnik/composing.png
>
> Legend:
> without effect     opacity(Your example)
> merge-grain(mine)  multiply(mapy.cz)

Thanks for the great help, it's very appreciated.

Cheers
  Colin
_______________________________________________
Mapnik-users mailing list
Mapnik-users@...
https://lists.berlios.de/mailman/listinfo/mapnik-users

Re: Different hillshading approaches

by Marcin Rudowski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/6/3 Colin Marquardt <cmarqu42@...>:

> 2009/6/3 Marcin Rudowski <mrudowski1@...>:
>> Colin Marquardt pisze:
>>> The relief layer is different of course, but not so much IMO:
>>> http://m4.mapserver.mapy.cz/relief-l/11_7e60000_8480000 vs.
>>> http://opentiles.com/cmarqu/tiles_relief/12/2209/1372.png
>>>
>>> Does anybody have a guess as to what the crucial difference is?
>>>
>> They are more different then You think. In Your case You shade
>> luminosity and assign opacity 0.7 (constant alfa). In mapy.cz image is
>> all black and in fact shaded alfa channel is making it look relief.
>>
>> Try to invert Your gray value and make it alfa of new black image.
>> Then simple composition with base layer without any additional opacity
>> change in OpenLayers should be enough.
>
> Wow, thanks very much for this. Now it's all clear...
>
> Can your Mapnik work that went into 0.6 produce just such tiles? When
> I use them to read the raster image created by hillshading.cpp from
> demtools, they are much more nicely smoothed, and it would be great to
> not have an additional step needed.
>

My work allow You to generate complete tiles with shading and content
in one step, also using 'multiply' method that gives effect that
mapy.cz use.

If You would like to have separate relief and content tiles using
mapnik, it can't generate such alfa encoded shading from simple shaded
raster.

Solution depends, If You want dynamic tile generation (on demand) or
one time seed (ie: tilecache_seed.py).

In dynamic case, I assume You use mapnik to cut and resize tiff
generated using demtools. To have: demtool->mapnik->WWW, You probably
need modyfying hillshading.cpp to generate output image like You need
(black piksels with computed values as alfa), because mapnik can't
change existing tiff like I described.

But there is still problem with png256 format conversion, as it is
extreme case of:
http://trac.mapnik.org/ticket/202
and any implementation wouldn't be as good as direct approach, that
doesn't needs palette computation, only using specific one (alfa[i]=i
and color[i]=black, i=0..255).

In case of static relief tiles, it would be easier to convert current
simple hillshaded tile images using palette manipulation only on gray
png256:
create tRNS from color palette(alfa value from gray value), and then
assign black to each position in color palette.


>> I tried this too when experimenting, but finally decided for different
>> approach (like gimp's merge-grain):
>> http://mapa.ump.waw.pl/ump-www/?zoom=10&lat=49.54125&lon=19.28081
>> https://lists.berlios.de/pipermail/mapnik-users/2009-February/001651.html
>
> Yes, I'm basically following your process on my "main map". IMHO the
> mapy.cz way looks a bit nicer, as it doesn't have the plastic-looking
> effect so much and leaves the colors intact.
>
> Do you think the separation of the tiles would help reducing colors
> and total size of tiles needed?
>

Check and share results :)  If I find some time (cpu time also :) )
I'll try to make tests on my own too.

As example downside of separate tiles: browser needs to make 2x more
http request and there are limits to maximum concurrent connections.

If size is reduced enough to compensate potential time increase due to
more files to download, it could be worth separating. Another
advantage is when You need to shade more then one tile source: relief
will be downloaded by browser only once.

--
Marcin Rudowski
_______________________________________________
Mapnik-users mailing list
Mapnik-users@...
https://lists.berlios.de/mailman/listinfo/mapnik-users