mapbox / mapboxgl-jupyter

Use Mapbox GL JS to visualize data in a Python Jupyter notebook
MIT License
661 stars 136 forks source link

Add function type "identity" to color, radius, height stops #144

Open ryanbaumann opened 5 years ago

ryanbaumann commented 5 years ago

Problem

As a data scientist or developer, I want to build an application where a visualization's "height", "radius", or "color" is encoded directly into the source data as a property - for example, `"height": 2001. This matters because I can create buildings that are the exact correct height in a 3D extrusion visualization.

Solution

Add identity function to https://github.com/mapbox/mapboxgl-jupyter/blob/6e9543462d149118fb81b0c9298bea1dd44a8be2/mapboxgl/viz.py#L589

akacarlyann commented 5 years ago

@ryanbaumann Would this be similar to setting height_function_type='match' and specifying the height_property='height'? It's a little clumsy, but just wanted to check if that's the same behavior you're looking for. I like your idea of including height_function_type='identity'. Then we can have the viz automatically specify the height property without the user having to edit two arguments.

ryanbaumann commented 5 years ago

@akacarlyann instead of using a height_function_type that was match, we want to create a Mapbox GL expression under the hood that sets the value from the data column directly equal to the value used in the map. The identity keyword would indicate to pass ['get', 'myColumnName]` as the expression to the layer created by the Python Viz function.

akacarlyann commented 5 years ago

@ryanbaumann cool cool. That's what I started in #161. Definitely nice to have this option.