Is there a method or any other way to obtain the underlying binned data from HexagonLayer ? I'd like to get the aggregate counts, hexagon centers (long and lat) or geometry. I am using pydeck to produce the visualization.
import pydeck as pdk
# Create the HexagonLayer
layer = pdk.Layer(
'HexagonLayer',
df,
get_position=['lng', 'lat'],
auto_highlight=True,
radius=radius,
elevation_scale=200,
pickable=True,
extruded=True,
wireframe=True,
coverage=1,
colorAggregation='SUM'
)
# Render the layer
r = pdk.Deck(layers=[layer], initial_view_state=view_state)
r.show()
# Get the underlying data
data = layer.get_data()
print(data.head())
For most types of Layers you can access the data via
layer.data. But you do have the data you gave to the Layer as a DataFrame. When accessing the data it will be in a different format.Also if you give a
GeoJsonLayeran URL you will get the URL and not the data. As the data is only fetched in the Browser not in the python environment. You would then have to use a callback to get the data. I am not sure if it is even possible to get the full dataset from a callback. You can get singular elements via the ClickInfo Event, but only if the Layer is pickable.EDIT: Just as a HeadsUp to anyone expecting to get GeoJson from a GeoJsonLayer.
layer.datadoes not store the actual geojson it is processed and the data that is stored inlayer.datadoes not conform to the GeoJson specification. If you look at it you will notice that the data has been flattened so that the properties are in the top level as siblings togeometry.