2

I am able to render a single COG (Cloud Optimized GeoTIFF) file using OpenLayers examples

But, when when I go for rendering of multiple COG files, then it gives error.

How can I render multiple COG files using Open Layers?

Source Code: https://openlayers.org/en/latest/examples/cog.html

This works (as single file working OK)

const source = new GeoTIFF({
    sources: [
        {
            url: 'https://indgeos-cog-test-1.s3.ap-south-1.amazonaws.com/cog0.tif'
        },
    ],
});

This Fails (as multiple files break)

const source = new GeoTIFF({
    sources: [
        {
            url: 'https://indgeos-cog-test-1.s3.ap-south-1.amazonaws.com/cog0.tif'
        },
        {
            url: 'https://indgeos-cog-test-1.s3.ap-south-1.amazonaws.com/cog1.tif'
        },
    ],
});

Error at Browser (on multiple rendering)

enter image description here

1

1 Answer 1

3

COGs within a GeoTIFF source must be able to use the same tile grid, but as in https://openlayers.org/en/latest/examples/multiple-cogs.html a layer can also have multiple GeoTIFF sources, so this should work

const source0 = new GeoTIFF({
  sources: [
    {
      url: 'https://indgeos-cog-test-1.s3.ap-south-1.amazonaws.com/cog0.tif'
    },
  ],
});

const source1 = new GeoTIFF({
  sources: [
    {
      url: 'https://indgeos-cog-test-1.s3.ap-south-1.amazonaws.com/cog1.tif'
    },
  ],
});

const layer = new TileLayer({
  sources: [source0, source1],
});
3
  • const layer = new TileLayer({ sources: [source0, source1], }); const map = new Map({ target: 'map', layers: layer, view: source.getView(), }); Commented Jan 28, 2023 at 17:40
  • getting error as 'source is not defined' . source here is the variable at last line. Can you further help me at rendering source ? Many Thanks Commented Jan 28, 2023 at 17:41
  • Do you mean source.getView()? Use either source0 or source1 (or if they cover different areas use PromiseAll and combine the extents as in openlayers.org/en/latest/examples/multiple-cogs.html)
    – Mike
    Commented Jan 28, 2023 at 17:59

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.