1

I have some GeoTIFF files that I want to render as an image mosaic layer in GeoServer. The files were created with gdal_grid, and they look fine in QGIS:

Screenshot of QGIS rendering the images in their proper orientation

And they look fine in GeoServer when loaded as individual GeoTIFF stores. Here's the larger of the two rendering in the GeoServer OpenLayers preview:

Screenshot of GeoServer layer preview rendering a single GeoTIFF correctly

But if I attempt to use an Image Mosaic store (using the exact same files, in the exact same directory), GeoServer renders them upside down. Each file is flipped within its own (correct) bounding box:

Screenshot of GeoServer layer preview rendering the GeoTIFFs upside down

Is there a way to get the Image Mosaic to render them in the proper orientation? I'd prefer not having to regenerate the images, but if there's a tweak to the gdal_grid command line that would make it work, that'd be fine too.

Both the images are in the "EPSG:4326" coordinate system.


gdalinfo output from one of the images:

$ gdalinfo bath-SCI-3sec.tif
Driver: GTiff/GeoTIFF
Files: bath-SCI-3sec.tif
Size is 1801, 601
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 = (-118.500416666666993,32.499583333333298)
Pixel Size = (0.000833333333334,0.000833333333333)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (-118.5004167,  32.4995833) (118d30' 1.50"W, 32d29'58.50"N)
Lower Left  (-118.5004167,  33.0004167) (118d30' 1.50"W, 33d 0' 1.50"N)
Upper Right (-116.9995833,  32.4995833) (116d59'58.50"W, 32d29'58.50"N)
Lower Right (-116.9995833,  33.0004167) (116d59'58.50"W, 33d 0' 1.50"N)
Center      (-117.7500000,  32.7500000) (117d45' 0.00"W, 32d45' 0.00"N)
Band 1 Block=1801x1 Type=Float32, ColorInterp=Gray

Command line used to make the image:

$ gdal_grid \
    -ot Float32 \
    -outsize 1801 601 \
    -txe -118.500416666667 -116.999583333333 \
    -tye 32.4995833333333 33.0004166666667 \
    -a nearest \
    -a_srs EPSG:4326 \
    bath-SCI-3sec.vrt \
    bath-SCI-3sec.tif

Contents of bath-SCI-3sec.vrt:

<OGRVRTDataSource>
    <OGRVRTLayer name="bath-SCI-3sec">
        <SrcDataSource relativeToVRT="1">bath-SCI-3sec.csv</SrcDataSource>
        <GeometryType>wkbPoint</GeometryType>
        <GeometryField encoding="PointFromColumns" x="field_1" y="field_2" z="field_3" />
    </OGRVRTLayer>
</OGRVRTDataSource>


Here is the (GeoServer-generated) properties file for the image mosaic:

#-Automagically created from GeoTools-
#Wed Jun 17 10:00:07 CDT 2020
MosaicCRS=EPSG\:4326
Levels=8.333333333351735E-4,8.333333333335202E-4
Heterogeneous=false
Name=bathymetry
HeterogeneousCRS=false
TypeName=bathymetry
Caching=false
ExpandToRGB=false
LocationAttribute=location
PathType=RELATIVE
SuggestedSPI=it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReaderSpi
CheckAuxiliaryMetadata=false
LevelsNum=1

Here's what GeoServer says about the Image Mosaic layer's CRS:

Image Mosaic layer CRS info

5
  • please add the gdalinfo output on the tiff
    – Ian Turton
    Jun 16, 2020 at 18:49
  • What GetMap requests are made by QGIS for each layer?
    – nmtoken
    Jun 16, 2020 at 20:52
  • @nmtoken QGIS is reading the GeoTIFF files directly.
    – csd
    Jun 16, 2020 at 21:01
  • what projection did you specify for the image mosaic?
    – Ian Turton
    Jun 17, 2020 at 7:30
  • I would try with out -a_srs EPSG:4326
    – Ian Turton
    Jun 18, 2020 at 8:08

1 Answer 1

1

Image mosaic cannot handle input images with any sort of affine transformation, this includes both rotation and flipping.

The situation could be rectified by changing the image mosaic code.

If you're interested in donating some of your time and work I'd suggest to subscribe to the GeoTools developer list and ask for directions (the image mosaic code lives in GeoTools).

If instead you're interested in funding the improvement, check the commercial support page at http://geoserver.org/support/ (disclaimer, I work for one of such organisations).

1
  • Aha, that's it. This image's pixels are written from the bottom up. When I change the order of the values in the -tye parameter, GDAL writes them top down and all is well.
    – csd
    Jun 18, 2020 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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