metacatui icon indicating copy to clipboard operation
metacatui copied to clipboard

Add interface that allows users to change the color palette of layers while viewing a Cesium map

Open robyngit opened this issue 4 years ago • 10 comments

Some data layers in Cesium will have additional attributes (beyond their coordinates) that we can use to colour-code the associated markers or polygons. For example, we could shade polygons according to an "area" attribute, or colour location markers by a "year" attribute.

A single data layer could have multiple attributes, some of which we would want to use for colour coding, some of which are not relevant (e.g. "Identifier"). A user viewing the map should be able to switch between relevant attributes.

We also need a way to indicate to Cesium which properties of a data layer should be colour-coded, and what kind of scale to use (e.g. a categorical or continuous? sequential or diverging?)

We should use scientifically derived colour palettes when implementing this, see Crameri, F., Shephard, G.E. & Heron, P.J. The misuse of colour in science communication. Nat Commun 11, 5444 (2020).

robyngit avatar May 19 '21 22:05 robyngit

Related to #1770

laurenwalker avatar May 20 '21 17:05 laurenwalker

Also related to #1768

robyngit avatar Jun 15 '21 20:06 robyngit

Example UIs from our mockups:

Screen Shot 2021-11-29 at 12 39 46 Screen Shot 2021-11-29 at 12 40 04

Example UIs from 'Cesium Stories':

Screen Shot 2021-11-29 at 12 41 48 Screen Shot 2021-11-29 at 12 41 22

robyngit avatar Nov 29 '21 17:11 robyngit

This topic came up in different meetings this week so I want to document and continue the discussion here:

@mbjones mentioned that the color of the PNG tiles can't be changed, so the tiles will need to be regenerated upon user config, which isn't feasible on the fly. Anna later had a good thought that we can generate a few sets of tiles using several predefined color schemes. The config on portal would let users choose among these color schemes for each layer.

This would solve two problems: 1. color collision as we add more layers, and 2. one roadblock to full automation

Questions:

  • Is it possible for a small set of color schemes to cover the use cases of most data types?
  • Is the extra PNG tile storage a concern?
  • Any other technical or product concerns?

cc: @julietcohen @westminsterabi

yvonnesjy avatar Feb 07 '24 23:02 yvonnesjy

We may be able to skip the PNG layer altogether now, as I have seen some discussion as of mid-2023 that Cesium can now directly render GeoTIFF layers with the TIFFImageryProvider plugin. This was not possible until recently. See: https://github.com/hongfaqiu/TIFFImageryProvider

This would provide a tremendous boost in functionality, and lower our processing needs by eliminating the png layers.

See conversation at: https://github.com/CesiumGS/cesium/issues/6332#issuecomment-1441389252

Here's an example from the API Documentation for setting custom colors in the JS:

TIFFImageryProvider.fromUrl(YOUR_TIFF_URL, {
  renderOptions: {
    single: {
      "colors": [
        [1, "rgb(154, 206, 127)"],
        [2, "rgb(163, 214, 245)"],
        [3, "rgb(255, 251, 177)"],
        [4, "rgb(193, 114, 97)"],
        [5, "rgb(220, 100, 120)"],
        [6, "rgb(49, 173, 105)"]
      ],
      type: "discrete",
      useRealValue: true // use real value in colors stops
    }
  }
});

mbjones avatar Feb 21 '24 22:02 mbjones

Oh, and @robyngit @yvonnesjy I'm not sure how well this Cesium TIFF library has been tested -- we'd need to vet it before heading too far down this route -- but promising!

mbjones avatar Feb 21 '24 23:02 mbjones

That's great for single GeoTiffs, but for displaying data across the entire arctic, wouldn't GeoTiffs generally be way too large? I thought that one of the advantage of PNGs for this purpose was their small filesize. Is there a way to create GeoTiffs that are equally as small?

robyngit avatar Feb 22 '24 15:02 robyngit

You can (and we do) tile geotiffs just like you do PNGs. So no difference there (we'd need to create the tile pyramid though). You can also create Cloud-Optimized GeoTIFFs (COGs) that are web-addressable on a per-tile chunk basis, making it possible to make efficient web requests for specific tiles from a much larger whole. And COGs can provide "overviews" that represent a tile pyramid to get lower-resolution views of the same data. Lots of work going on in this space over the last several years, and there are a bunch of great overviews/tutorials on it on the interwebs.

mbjones avatar Feb 22 '24 21:02 mbjones

FYI @hngrtr- rendering arbitrary colors configured through the UI might be a possibility.

yvonnesjy avatar Feb 23 '24 05:02 yvonnesjy

I spent some time trying to get the TIFFImageryProvider to work, and it does work well to load a single GeoTIFF, but there will be a good amount of work to try to build a provider that will issue requests for individual tiles. Right now this library seems to handle tiling for single COGs. I tried, and was not able to get an MVP working for requesting multiple GeoTIFFs. There is an issue on that library mentioning the same idea.

ianguerin avatar May 17 '24 20:05 ianguerin