CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
12.91k stars 3.48k forks source link

Support for Cloud Optimized GeoTIFF #6332

Open pjcozzi opened 6 years ago

pjcozzi commented 6 years ago

https://trac.osgeo.org/gdal/wiki/CloudOptimizedGeoTIFF

Basically a GeoTIFF with tiles that can be served without a full tile server.

A good starting place could be this OpenLayers viewer by @cholmes: https://github.com/cholmes/cog-map

Could be a great code sprint project!

cholmes commented 6 years ago

Note that the openlayers viewer users an AWS lambda tile server. Though you're more than welcome to hit that tile server until I run out of credits. Could make a similar interaction easily.

The other thing to note is https://github.com/constantinius/geotiff.js/issues/36 - this should hopefully be a pure JS library that cesium would be able to use. cc @constantinius

mramato commented 6 years ago

I was under the impression that cloud-optimized geotiffs were more for on-demand tiling using something like AWS lambda reading from a GeoTIFF stored on S3 (ideal for "serverless" but not something Cesium can do completely client side. Because of things like band data type, projection, compression, etc.. it would be really hard for Cesium to ingest the image as tiles without a server.

That being said, I would love to be wrong.

cholmes commented 6 years ago

Yeah, it's still an experiment that needs to be done, but if @constantinius is successful it should open the way for cesium. We've also contemplated a cloud optimized geotiff profile for a 'web cog', see https://github.com/locationtech/geotrellis/issues/2284 - it'd be web mercator with tiles that match web tiles, and would have RGB, etc.

But yes, using COG's with on-demand tiling with geotiffs on S3 works today and would definitely be the place to start.

mramato commented 6 years ago

Sounds promising, thanks for the info.

constantinius commented 6 years ago

Hi folks!

I was under the impression that cloud-optimized geotiffs were more for on-demand tiling using something like AWS lambda reading from a GeoTIFF stored on S3 (ideal for "serverless" but not something Cesium can do completely client side. Because of things like band data type, projection, compression, etc.. it would be really hard for Cesium to ingest the image as tiles without a server.

GeoTIFF.js is capable of (or will soon be) handling all data abstraction stuff (remote reading, all kinds of tiling, compression, etc). It can read the actual raster values (TypedArrays) which can then be visualized. For single band false color visualization there is a good library that works well with the parsed data.

What we are currently thinking about is a JS library that creates nice RGB views of e.g Landsat images using various techniques like contrast stretching etc.

What is missing is handling the reprojection of the images to map them on the cesium globe. OpenLayers is capable of this, maybe it is possible to extract this piece and make it commonly available.

Those are the available/missing pieces, as we see it.

Thanks for connecting @cholmes

mramato commented 6 years ago

They recently launched http://www.cogeo.org/ which does a good job of summarizing everything. Also, every is just calling them COGs now.

Eugene from Azavea gave a good talk on it at FOSS4GNA as well, not sure when/if his slides will get posted: https://2018.foss4g-na.org/session/best-practice-serving-cog-imagery-using-mapserver-cloud-sponsored-aws

lossyrob commented 6 years ago

Slides here: https://2018.foss4g-na.org/sites/default/files/slides/FOSS4G%20NA%202018%20-%20Cloud%20Optimized%20GeoTiffs.pdf

pjcozzi commented 6 years ago
philip-firstorder commented 5 years ago

I successfully implemented Google COGs on Google Maps with Geotiff.js and now I am implementing Cesium. I will be looking on this functionality and let you know of my progress.

cr8tpro commented 4 years ago

Hi @philip-firstorder. Is there any update with your implementation. I am using Cesium for my project and it's very helpful if I can render COGs on mapviewer. Let me know if there is any updates.

philip-firstorder commented 4 years ago

Hello,

On fileorder.io you can create an account and upload COGs. Then just right-click the image and click View On Maps, you will then see your COG on Google Maps.

For Cesium I was delayed by some other developments and didn't get to implement COG on it yet.

abhijitgujar86 commented 2 years ago

any update on the COG support ?

hongfaqiu commented 1 year ago

Hi @abhijitgujar86 , I just created a cesium plugin TIFFImageryProvider, which support Load and render Cloud optimized GeoTIFF on Cesium.

jo-chemla commented 1 year ago

I just created a cesium plugin TIFFImageryProvider,

Wonderful, thanks for sharing! I just tried to load a custom landsat COG on your online demo (the one used on the OpenLayers example), but it could not load, do you know why? No error in the console, just an out-of-memory error in chrome and the tab crashes.

hongfaqiu commented 1 year ago

@jo-chemla Hello, I have solved this problem, now you can add the OpenLayers example through my online demo

jo-chemla commented 1 year ago

Thanks, working great! RGB channels seem to be inverted with other COGs like this one, but this should be easy to fix directly within the code. By the way, nice layer tree component [edit] with the source here

hongfaqiu commented 1 year ago

@jo-chemla Thank you for your suggestion, as the readme says, you can customize the band of rgb channel. (Maybe I should provide more rendering configurations in the demo) The layer tree was created with react-sortable-hoc, and you can copy the code from demo folder.

hongfaqiu commented 1 year ago

@jo-chemla I added a multi-band/ single-band rendering configuration in the demo. You can try it.

ilyaly commented 1 year ago

@hongfaqiu , thanks for sharing, great job!

@jo-chemla , can you please describe how you've fixed the problem with inverted colors?

hongfaqiu commented 1 year ago

@ilyaly, are you referring to the three-band rendering in TIFFImageryProvider? According to the API documentation, you can set the r, g, and b options to the corresponding color band index of the TIFF image. Here's an example code snippet for your reference:

const provider = new TIFFImageryProvider({
  url: 'YOURTIFF.tif',
  renderOptions: {
    r: { band: 4 },
    g: { band: 3 },
    b: { band: 2 },
  }
});

Hope this helps!

Great news! I have added WebGL support to the continuous color interpolation feature, which has significantly improved rendering speed. You are welcome to try it out and experience the difference!

ilyaly commented 1 year ago

@hongfaqiu , thank you for your reply!

Yeah I am talking about the three-band rendering. I do understand how to configure bands order but still cant reach a desired appearance.

For reference here is how this raster is displayed in COG Explorer:

image

And here is how it is displayed in your demo app:

image

hongfaqiu commented 1 year ago

@ilyaly It seems like there is a bug, I suggest you to raise an issue in my repo, and I will fix it soon.

constantinius commented 1 year ago

@hongfaqiu This is probably due to a difference in the color representation. geotiff.js has a readRGB method, that translates to RGB colorspace.

hongfaqiu commented 1 year ago

@constantinius Thank you for your help. I have just seen your message now. As you said, the problem has been resolved and it is now working properly.