Colin Marquardt pisze:
2009/3/21 Dane Springmeyer <[email protected]>:
These patches are not yet in svn.

They are now since Artem committed them in
http://trac.mapnik.org/changeset/1027, so they will be in Mapnik
0.6.0, great.

Great :)

Marcin, would you mind describing a bit more which exact parameters
you used for your nice Poland maps?


In osm.xml I use files from attachments: dem_styles.xml and dem_layers.xml. There are also defined scaled versions to avoid time and memory consuming downscaling.

Layer dem* are just after coastlines, "leisure-big" and "leisure" (all forests, industrials, aeroways and any areas other then water). I have almost all polygons without transparency, only housing and city range areas are transparent:
http://mapa.ump.waw.pl/ump-www/?zoom=12&lat=52.99057&lon=18.49656&layers=B00000T

So basically You draw "background" layers that should be shaded, then shading layer and then the rest (roads, icons, lakes, rivers, other polylines ...).

Hill shading is done using new merge method: grain_merge, where output pixel value are evaluated using:
I+M-0.5
where I is intensity of source (already drawn layers) and M is mask, both in 0..1 scale.

I would suggest experimenting also with multiply2, because with some gimp corrections (increasing or decreasing contrast/gamma in <0.5 and >0.5 range), could give better effects (less influence to color, only intensity shading). Both grain_merge and multiply2 makes background unchanged for shading mask value: 0.5 (or 128 in 0..255 scale).

As for preparations:
gdal_merge.py -v -o ../srtm.tif *.hgt
gdalwarp -of GTiff -srcnodata 32767 -dstnodata 32767 -s_srs \
   "+proj=latlong +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 \
   +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgri...@null +no_defs +over" \
   -t_srs "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 \
   +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgri...@null +no_defs +over" \
   -rcs -order 3 -tr 76.437 76.437  -wt Float32 -ot Float32 \
   srtm.tif warped.tif
./hillshade warped.tif hill_8.tif -z 3

Adjust -z to Your needs and land characteristic.

Latest gdal is able to correctly interpret hgt files, just naming is important.

I don't remember what I used to fill holes in hgt files, but it was probably some Windows or commandline application. I did all of preparations once, and now just use generated tiffs.

hillshade is basically from demtools with simple modification to move mean value (ie. gray value of flat land) to middle of scale (128) by adding correction:

cang -= sin(alt*degreesToRadians)-0.5;

This way grain merge will leave intensity unchanged on flat areas and mean intensity of map will be similar to one before shading.
Here is version I modified and used:
http://marcom.homeip.net/ump-www/demtools.tgz

You could also skip this fix and use multiply merge method. Mean output intensity will be lower, but without areas overflowing intensity scale:
http://mapa.ump.waw.pl/ump-www/?zoom=13&lat=49.79812&lon=19.80539&layers=B00000T
Choose what You find best for Your map.

To generate lower resolutions images You could probably use different values for "-tr 76.437 76.437" gdalwarp command (power of 2), ie: 152.874, 305.748, ..., but scaling parameter to hillshade command is needed accordingly. I haven't tried it anyway, just scaled tiff using gimp and forced proper geotags with gdal :)


I hope this is enough, because I didn't understand some of the terms You used in Your questions, so I only described what I did :)

For areas bigger then Poland (are there bigger Countries then Poland? ;) ) problem could be aligning separate rasters. I use one big tiff (200MB) and gdal should allow much bigger files, but I'm not sure if mapnik does. I didn't try using adjacent rasters for hillshading, but expect artifacts (~1px strips with double hillshading effect?). Probably more careful aligning to image resolution would be needed: making sure pixels from rasters are aligned with pixels of output. Now I only matched resolutions (magic 76.437 value), to avoid artifacts when upscaling.


BTW. as for big tiffs, I have some problems with segmentation faults. I believe its thread unsafe libtiff (60% of stacktraces are there originated) on mapnik initialization step, when big geotiff is analyzed for the first time (reading tiff headers and tags?). The bigger tiffs, more time it takes to initialize and bigger chance for segmentation faults. If renderd finally reads osm.xml file in each thread, everything is fine, only parsing/loading step(load_map(...) ) is multithread unstable. When I added 2-3s delay between thread creations, I have almost no such problems, so I ignored it meantime. I think with latest(1 month ago svn) mapnik and mod_tile/renderd I had the same problem & "solution" (delayed thread creation). Anyway for day to day generating Poland I still use self-patched mapnik-0.5.1, and quite old mod_tile apache module.

Regards,
Marcin Rudowski
<Layer name="dem30" status="on" >
    <StyleName>raster30</StyleName>
    <Datasource>
        <Parameter name="type">gdal</Parameter>
        <Parameter name="file">&geotiffs;/hill_30n.tif</Parameter>
        <Parameter name="format">tiff</Parameter>
    </Datasource>
</Layer>
<Layer name="dem15" status="on" >
    <StyleName>raster15</StyleName>
    <Datasource>
        <Parameter name="type">gdal</Parameter>
        <Parameter name="file">&geotiffs;/hill_15n.tif</Parameter>
        <Parameter name="format">tiff</Parameter>
    </Datasource>
</Layer>

<Layer name="dem8" status="on" >
    <StyleName>raster8</StyleName>
    <StyleName>raster4</StyleName>
    <Datasource>
        <Parameter name="type">gdal</Parameter>
        <Parameter name="file">&geotiffs;/hill_8n.tif</Parameter>
        <Parameter name="format">tiff</Parameter>
    </Datasource>
</Layer>
<Style name="raster4">
    <Rule>
        <MaxScaleDenominator>50000</MaxScaleDenominator>
        <RasterSymbolizer>
            <CssParameter name="opacity">1.0</CssParameter>
            <CssParameter name="scaling">bilinear</CssParameter>
            <CssParameter name="mode">grain_merge</CssParameter>
        </RasterSymbolizer>
    </Rule>
</Style>
<Style name="raster8">
    <Rule>
        <MaxScaleDenominator>250000</MaxScaleDenominator>
        <MinScaleDenominator>50000</MinScaleDenominator>
        <RasterSymbolizer>
            <CssParameter name="opacity">1.0</CssParameter>
            <CssParameter name="scaling">bilinear</CssParameter>
            <CssParameter name="mode">grain_merge</CssParameter>
        </RasterSymbolizer>
    </Rule>
</Style>
<Style name="raster15">
    <Rule>
        <MaxScaleDenominator>1000000</MaxScaleDenominator>
        <MinScaleDenominator>250000</MinScaleDenominator>
        <RasterSymbolizer>
            <CssParameter name="opacity">1.0</CssParameter>
            <CssParameter name="scaling">bilinear</CssParameter>
            <CssParameter name="mode">grain_merge</CssParameter>
        </RasterSymbolizer>
    </Rule>
</Style>

<Style name="raster30">
    <Rule>
        <MaxScaleDenominator>5000000</MaxScaleDenominator>
        <MinScaleDenominator>1000000</MinScaleDenominator>
        <RasterSymbolizer>
            <CssParameter name="opacity">1.0</CssParameter>
            <CssParameter name="scaling">bilinear</CssParameter>
            <CssParameter name="mode">grain_merge</CssParameter>
        </RasterSymbolizer>
    </Rule>
</Style>
_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users

Reply via email to