Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
robyngit opened this issue May 19, 2021 · 10 comments
Labels
cesium enhancement pdg Permafrost Discovery Gateway

Comments

@robyngit
Copy link
Member

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 robyngit added enhancement pdg Permafrost Discovery Gateway cesium labels May 19, 2021
@laurenwalker
Copy link
Member

Related to #1770

@robyngit
Copy link
Member Author

Also related to #1768

robyngit added a commit that referenced this issue Sep 29, 2021
Reorganization of the CesiumWidget:
- Move functions that create and update Cesium assets (e.g. imagery, terrain, 3Dtiles) from the CesiumWidget view to individual "Map Asset" models
- Replace the Layer and Terrain model with a more generic MapAsset model.
- Similarly, replace Layers and Terrains collections with a MapAssets collection that can be used in either case.

New features:
- Enable clicking on individual features in a 3D tileset lay to view more details
- Add support for configuring the colours to use for 3D tilesets - colors can be set conditionally in the Cesium config based on feature properties. Only categorical color palettes are enabled at so far.
- Add support for configuring 'vector filters' in the Cesium config. These filters conditionally show or hide features of a 3D tileset based on properties of the features.

Relates to #1770, #1798, #1789, #1790, #1791, #1780, #1778, #1797
@robyngit robyngit changed the title Enable colour-coding map entities by the different attributes of a data layer Add interface that allows users to change the color palette of layers while viewing a Cesium map Nov 29, 2021
@robyngit
Copy link
Member Author

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

@yvonnesjy
Copy link
Collaborator

yvonnesjy commented Feb 7, 2024

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

@mbjones
Copy link
Member

mbjones commented Feb 21, 2024

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: CesiumGS/cesium#6332 (comment)

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
Copy link
Member

mbjones commented Feb 21, 2024

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!

@robyngit
Copy link
Member Author

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?

@mbjones
Copy link
Member

mbjones commented Feb 22, 2024

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.

@yvonnesjy
Copy link
Collaborator

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

@robyngit robyngit modified the milestone: 2.30.0 Apr 18, 2024
@ianguerin
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cesium enhancement pdg Permafrost Discovery Gateway
Projects
None yet
Development

No branches or pull requests

5 participants