leafem icon indicating copy to clipboard operation
leafem copied to clipboard

allow pmtiles styles to map aesthetics to data properties?

Open cboettig opened this issue 1 year ago • 2 comments

the examples in PMTiles here show aesthetics like fill color as literal hex color values in the style, rather than being mapped to data columns:

paintRules(
  layer,
  fillColor = "#0033ff66",
  color = "#0033ffcc",

Some pmtiles rendering tools seem to support an additional syntax to map attributes to columns, e.g. https://maplibre.org/maplibre-style-spec/expressions/#get, as seen in this example https://maplibre.org/maplibre-gl-js/docs/examples/data-driven-lines/. Is it possible to support this?

cboettig avatar Mar 19 '24 03:03 cboettig

It certainly should be. I will try to find some time to make it work

tim-salabim avatar Mar 19 '24 08:03 tim-salabim

Awesome, thanks!

Just exploring the maplibre docs a bit more and I realize they have a really rich syntax for these operations, not just specifying literal colors in a data-column, but expressing abstract color ramps from the data values (for both discrete and continuous data).

It may be possible to cover some of the most common cases in a familiar R syntax, but might be simpler to expose an 'escape hatch' of letting users provide literal style json blobs. Consider this beautifully rich set of paint rules from another example in their docs:

 'paint': {
                'fill-color': [
                    'let',
                    'density',
                    ['/', ['get', 'population'], ['get', 'sq-km']],
                    [
                        'interpolate',
                        ['linear'],
                        ['zoom'],
                        8,
                        [
                            'interpolate',
                            ['linear'],
                            ['var', 'density'],
                            274,
                            ['to-color', '#edf8e9'],
                            1551,
                            ['to-color', '#006d2c']
                        ],
                        10,
                        [
                            'interpolate',
                            ['linear'],
                            ['var', 'density'],
                            274,
                            ['to-color', '#eff3ff'],
                            1551,
                            ['to-color', '#08519c']
                        ]
                    ]
                ],
                'fill-opacity': 0.7
            }

cboettig avatar Mar 20 '24 04:03 cboettig