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

allow pmtiles styles to map aesthetics to data properties? #76

Open
cboettig opened this issue Mar 19, 2024 · 2 comments
Open

allow pmtiles styles to map aesthetics to data properties? #76

cboettig opened this issue Mar 19, 2024 · 2 comments

Comments

@cboettig
Copy link

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?

@tim-salabim
Copy link
Member

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

@cboettig
Copy link
Author

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
            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants