1

I have a Float32 GeoTiff image(DEM image) that I published on my GeoServer instance. Image is being displayed correctly in QGIS but GeoServer is always returning black image. I generated style inside QGIS and uploaded it on GeoServer and it looks like this:

<?xml version="1.0" ?>
<sld:StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:sld="http://www.opengis.net/sld">
    <sld:UserLayer>
        <sld:LayerFeatureConstraints>
            <sld:FeatureTypeConstraint/>
        </sld:LayerFeatureConstraints>
        <sld:UserStyle>
            <sld:Name>dem</sld:Name>
            <sld:Title/>
            <sld:FeatureTypeStyle>
                <sld:Name/>
                <sld:Rule>
                    <sld:RasterSymbolizer>
                        <sld:Geometry>
                            <ogc:PropertyName>grid</ogc:PropertyName>
                        </sld:Geometry>
                        <sld:Opacity>1</sld:Opacity>
                        <sld:ColorMap>
                            <sld:ColorMapEntry color="#000000" opacity="1.0" quantity="-0.201920061588287"/>
                            <sld:ColorMapEntry color="#FFFFFF" opacity="1.0" quantity="3.4618512865901"/>
                        </sld:ColorMap>
                    </sld:RasterSymbolizer>
                </sld:Rule>
            </sld:FeatureTypeStyle>
        </sld:UserStyle>
    </sld:UserLayer>
</sld:StyledLayerDescriptor>

But it still gives me completely black image.

http://localhost:8080/geoserver/TEST_MILOS_DEM/wms?service=WMS&version=1.1.0&request=GetMap&styles=dem&layers=TEST_MILOS_DEM%3AMajorka2_ElevationToolbox_export_TueMay14123035.692089&bbox=2.8199672698974667%2C39.64482498480215%2C2.8227136856354664%2C39.64627901887387&width=768&height=406&srs=EPSG%3A4326&format=application/openlayers

Also gdalinfo for this particular image looks like this:

gdalinfo -hist

Driver: GTiff/GeoTIFF
Files: C:/Users/milos/Desktop/Majorka2_ElevationToolbox_export_TueMay14123035.692089.tif   C:/Users/milos/Desktop/Majorka2_ElevationToolbox_export_TueMay14123035.692089.tif.aux.xml
Size is 6558, 3472
Coordinate System is:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433],
    AUTHORITY["EPSG","4326"]]
Origin = (2.819967269897467,39.646279018873869)
Pixel Size = (0.000000418788615,-0.000000418788615)
Metadata:
  acquisitionEndDate=2017-09-01T10:47:52.401000+00:00
  acquisitionStartDate=2017-09-01T10:17:52.401000+00:00
  AREA_OR_POINT=Area
  isCalibrated=False
Image Structure Metadata:
  COMPRESSION=DEFLATE
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (   2.8199673,  39.6462790) (  2d49'11.88"E, 39d38'46.60"N)
Lower Left  (   2.8199673,  39.6448250) (  2d49'11.88"E, 39d38'41.37"N)
Upper Right (   2.8227137,  39.6462790) (  2d49'21.77"E, 39d38'46.60"N)
Lower Right (   2.8227137,  39.6448250) (  2d49'21.77"E, 39d38'41.37"N)
Center      (   2.8213405,  39.6455520) (  2d49'16.83"E, 39d38'43.99"N)
Band 1 Block=256x256 Type=Float32, ColorInterp=Gray
  Min=-0.357 Max=6.116 
  Minimum=-0.357, Maximum=6.116, Mean=0.887, StdDev=0.940
  256 buckets from -0.369967 to 6.12851:
  621 438 800 1859 4899 21144 127282 261572 263423 267997 237222 213122 231558 236234 240664 240534 237613 221211 204965 187827 199631 184601 173180 173065 181927 175983 168795 154891 148781 157180 149247 153438 148713 160510 146394 134223 124750 128537 125447 123732 123499 130718 134618 133011 134542 145060 152420 167042 170089 167358 167689 152095 152670 150694 155156 150435 134805 120697 122747 118291 122150 120902 117297 108603 95362 87800 87159 87915 85040 81797 85311 77722 76007 77394 72816 71768 69636 70336 69825 75109 75378 74350 70971 67067 64162 60736 56766 54861 52441 50684 45633 42994 41937 39617 37443 35854 34709 33710 32968 30998 29242 27430 25491 24014 23607 22436 20791 19538 18824 18266 17422 16416 15522 14762 14209 12984 11726 11159 10739 10431 9477 9320 9125 8538 7333 6823 6297 5884 5359 4956 4967 4360 3832 3525 3305 2957 2567 2224 2025 1754 1595 1523 1493 1460 1378 1436 1400 1405 1420 1475 1606 1604 1587 1589 1477 1561 1637 1664 1674 1696 1765 1624 1627 1619 1683 1602 1648 1753 1738 1881 1749 1675 1655 1707 1606 1614 1583 1414 1361 1493 1410 1232 1190 1124 1069 957 960 794 807 781 695 605 589 584 477 439 443 403 392 361 402 410 307 363 378 378 375 325 319 351 377 311 378 441 522 530 447 429 391 346 351 290 326 253 235 239 226 213 203 186 192 172 133 119 118 127 131 113 129 129 150 176 193 187 171 200 200 193 224 250 237 226 204 219 258 2756 
  NoData Value=-32767
  Metadata:
    STATISTICS_MAXIMUM=6.1158199310303
    STATISTICS_MEAN=0.88688031177247
    STATISTICS_MINIMUM=-0.35727432370186
    STATISTICS_STDDEV=0.93983007339332

Is there a problem for Float32 data type in GeoServer or am I doing something wrong?

  • the max of your image is 6.12 while you only stretch upto 3.461 – Ian Turton May 14 at 14:54
  • Qgis is displaying normally image using that same style. Nonetheless, I tried increasing second quantity value to 6.12, but it's the same. – Milos Miletic May 14 at 14:57
  • try using the default raster style – Ian Turton May 14 at 15:22
  • It's still the same, black image. – Milos Miletic May 14 at 15:28
  • can you share the image? – Ian Turton May 14 at 15:44
1

Try using something like (from https://docs.geoserver.org/stable/en/user/styling/sld/reference/rastersymbolizer.html#contrastenhancement):

<ContrastEnhancement>
  <Normalize>
   <VendorOption name="algorithm">StretchToMinimumMaximum</VendorOption>
   <VendorOption name="minValue">-1</VendorOption>
   <VendorOption name="maxValue">7</VendorOption>
  </Normalize>
</ContrastEnhancement>
  • Unfortunately it didn't work. I tried multiplying raster by 100 and then it worked out of the box, without applying any style. Computed Min/Max=-77.755,721.392. Is there maybe a problem when values are in really small range? – Milos Miletic May 15 at 15:41
  • your image worked fine using my example above – Ian Turton May 15 at 15:49
1

I am encountering the same issue with a black image. My source DEM is ArcticDEM, which is Float32. Applying ContrastEnhancement in the style did not help, but I was able to convert to Int16 using GDAL and the resulting image works in GeoServer 2.15.1 (JDK 11.0.2).

$ gdal_translate -a_srs EPSG:4326 -a_nodata -9999.0 -ot Int16 -of GTiff -co COMPRESS=DEFLATE -co PREDICTOR=2 -co ZLEVEL=9 arcticdem_500m_4326.tif arcticdem_500m_4326_int.tif

(In my case I have already re-projected the DEM to EPSG:4326 for testing.)

This isn't the best solution as the conversion will discard some data, but if you find the data degradation to not affect your output then it might work for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.