4

I need to display a raster image in GeoTiff format, it was georeferenced with QGIS. It looks like Openlayers 3.15 doesn't support this kind of format. Do you know anything about that?

var agentUrl = 'http://localhost:9925/Wgis/assets/img/allertaMeteoGeo.tif';

    var bounds = [ 713101.704, 4044061.027, 713101.704, 4044061.027];



    var view2 = new ol.View({
        center : [ -87.7302542509315, 43.744459064634 ],
        projection : "EPSG:3857",
        zoom : 12
    });

    var sorgente = new ol.source.ImageMapGuide({
        projection : "EPSG:3857",
        url : agentUrl,
        metersPerUnit : 111319.4908,

        imageSize: [792, 452],
        ratio : 2
    });

    var raster = new ol.layer.Image({
        extent : bounds,
        source : sorgente
    });

    var map2 = new ol.Map({
        layers : [ raster ],
        target : 'map2',
        view : view2
    });
ahocevar
  • 5,448
  • 15
  • 29
  • I don't think it's possible, see also these questions on the GIS SE: http://gis.stackexchange.com/questions/15095/how-to-display-a-geotiff-image-with-openlayers-at-the-right-place http://gis.stackexchange.com/questions/97943/how-to-open-geotiff-as-base-layer-on-openlayers – chrki May 27 '16 at 13:12
  • Is this still available for version 4? Did you found a solution? – Daniel Dudas Nov 03 '17 at 11:25

2 Answers2

4

I agree with chrki, that it is not currently possible to display a TIFF (or GeoTiFF) in an OpenLayers map as stated here: https://gis.stackexchange.com/a/98029. Browsers do not display TIFF images natively.

As an experiment, I exported both TIFF and PNG files from an ArcGIS raster image. Then in an openlayers map (using v3.18.2), I used the following function to successfully add a PNG as an ol.layer.Image, but it failed without notice for the TIFF:

function addImage() {

    extent = [-13602803.9769, 4920816.12423, -13599949.5192, 4923458.74552]; // [left, bottom, right, top]

    var projection = new ol.proj.Projection({
        code: 'xkcd-image',
        units: 'pixels',
        extent: extent
    });

    var StaticImage = new ol.layer.Image({
        source: new ol.source.ImageStatic({
        attributions: 'yada yada',
        url: /robs/gis_data/LiDAR Elevations2.png',
        projection: projection,
        imageExtent: extent
        })
    });    

    map.addLayer(StaticImage);
    map.getView().fit(extent, map.getSize());    
} 
Community
  • 1
  • 1
Rob Irwin
  • 123
  • 11
2

Actually you could tile your image before, load it in IIS and get it from something like this:

var newLayer = new ol.layer.Tile({
source: new ol.source.OSM({
        url: 'maps/{z}/{x}/{y}.png'
})});
FriendsKenny
  • 150
  • 3
  • 11