Skip to main content
2 of 4
added 5 characters in body
Magno C
  • 2.2k
  • 3
  • 25
  • 65

Well, after my EDIT 3 I found this post: How to antialiase tiles when seeding a layer from an GeoTiff in GeoServer

In GeoServer under the point WMS you can activate antialiasing. This was already checked but the raster rendering option was nearest neighbor. I switched it to bilinear or bicubic and now the resulting tiles are nice and smooth looking. (User: strangeoptics)

I changed it to bilinear and now I can see this nice result. I've noticed some horizontal lines and found no way do get rid of them:

enter image description here

The final setting is:

1) Get the HGT files and create contour lines to import to OSM:
    phyghtmap --pbf --srtm=1 --a -43.7544:-23.2363:-42.0378:-22.3183 --earthdata-user=myuser --earthdata-password=mypassword

2) Create VRT from the HGT files:
    gdalbuildvrt ./teste.vrt hgt/SRTM1v3.0/S23W043.hgt  hgt/SRTM1v3.0/S23W044.hgt  hgt/SRTM1v3.0/S24W043.hgt  hgt/SRTM1v3.0/S24W044.hgt

3) Do the abracadabra: 
    gdal_translate -tr 0.000050 0.000050 -r cubicspline -of GTiff test.vrt test.tif

4) And now do some kung-fu-code:
    gdaldem hillshade -co TILED=YES -co compress=lzw -s 111120 -z 5 -combined -compute_edges test.tif final.tif

5) Import contour lines to OSM. I prefer to create a separate database and give a small `.style` to import just the needed columns.
    osm2pgsql --verbose --create --style ./srtm.style --database contour --username postgres -W --host 127.0.0.1 lon-43.23_-43.05lat-23.00_-22.90_srtm1v3.0.osm.pbf
    osm2pgsql --verbose --append <all other pbf files> (be careful with --append parameter) 

This is the style file used:

srtm.style
# OsmType Tag DataType Flags
node,way contour text linear
node,way contour_ext text linear
node,way ele text linear

Applied this style to the raster layer (GeoTiff Coverage Store pointed to final.tif):

<?xml version="1.0" encoding="UTF-8"?>
<sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" version="1.0.0">
  <sld:UserLayer>
    <sld:LayerFeatureConstraints>
      <sld:FeatureTypeConstraint/>
    </sld:LayerFeatureConstraints>
    <sld:UserStyle>
      <sld:Title/>
      <sld:FeatureTypeStyle>
        <sld:Name>name</sld:Name>
        <sld:FeatureTypeName>Feature</sld:FeatureTypeName>
        <sld:Rule>
          <sld:MinScaleDenominator>5000</sld:MinScaleDenominator>
          <sld:RasterSymbolizer>
            <sld:Geometry>
              <ogc:PropertyName>grid</ogc:PropertyName>
            </sld:Geometry>
            <sld:ColorMap>
                <ColorMapEntry color="#000000" quantity="0.0" label="low" opacity="0.0"/>
                <ColorMapEntry color="#999999" quantity="1.0" label="high" opacity="0.75"/>
                <ColorMapEntry color="#FFFFFF" quantity="256" label="alpha" opacity="0.75"/> 
            </sld:ColorMap>
          </sld:RasterSymbolizer>
        </sld:Rule>
        <sld:VendorOption name="composite">multiply</sld:VendorOption>
      </sld:FeatureTypeStyle>
    </sld:UserStyle>
  </sld:UserLayer>
</sld:StyledLayerDescriptor>

Do not ask me anything because actualy I have no idea what I've done. Just getting ideas from thousands sources and adjusting to fit my needs. BTW: The result file is very huge but seems Geoserver knows how to handle it.

Magno C
  • 2.2k
  • 3
  • 25
  • 65