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

feat(pydeck): support v9 in bindings #8227

Closed
Jesus89 opened this issue Oct 26, 2023 · 2 comments · Fixed by #8577
Closed

feat(pydeck): support v9 in bindings #8227

Jesus89 opened this issue Oct 26, 2023 · 2 comments · Fixed by #8577
Assignees
Milestone

Comments

@Jesus89
Copy link
Collaborator

Jesus89 commented Oct 26, 2023

Target Use Case

Provide a new version of pydeck and pydeck-carto that uses deck.gl version 9.

Proposal

Adapt the changes of v9 to the following packages:

pydeck

Test pydeck with deck.gl v9 and prepare the required changes.

Release new beta version 0.9.0b1.

pydeck-carto

Test pydeck-carto with deck.gl v9 and prepare the required changes.

Release new beta version 0.2.0b1.

RFC: https://github.com/visgl/deck.gl/blob/master/dev-docs/RFCs/v8.0/carto-v9-rfc.md
Tracker: #8148

@Jesus89 Jesus89 self-assigned this Oct 26, 2023
@Jesus89 Jesus89 added the pydeck label Oct 26, 2023
@ibgreen ibgreen changed the title [Feat] support v9 in bindings feat(pydeck): support v9 in bindings Oct 26, 2023
@Jesus89
Copy link
Collaborator Author

Jesus89 commented Nov 7, 2023

I've analyzed the changes:

  • pydeck: there are no API changes, just test that all the layers work as expected
  • pydeck-carto: there is a new API that needs to be mapped in python

Sources

  • VectorTableSource: table_name
  • VectorQuerySource: sql_query
  • VectorTilesetSource: table_name
  • H3TableSource: table_name
  • H3QuerySource: sql_query
  • H3TilesetSource: table_name
  • QuadbinTableSource: table_name
  • QuadbinQuerySource: sql_query
  • QuadbinTilesetSource: table_name
  • RasterTilesetSource (experimental): table_name

Layers

  • H3TileLayer: get_hexagon
  • QuadbinTileLayer: get_quadbin
  • VectorTileLayer
  • RasterTileLayer (experimental)
import pydeck as pdk
import pydeck_carto as pdkc
from carto_auth import CartoAuth

# Authentication with CARTO
carto_auth = CartoAuth.from_oauth()

# Register CARTO layers in pydeck
pdkc.register_layers()

# Create source
data = pdkc.vector_query_source(
    sql_query="...",
    connection_name="carto_dw",
    access_token=pdkc.get_access_token(carto_auth),
    api_base_url=pdkc.get_api_base_url(carto_auth))

# Create layer
layer = pdk.Layer(
    "VectorTileLayer",
    data=data,
    get_fill_color=[238, 77, 90],
    point_radius_min_pixels=2.5,
    pickable=True)

# Render layer
pdk.Deck(
    layer,
    map_style=pdk.map_styles.ROAD,
    initial_view_state=pdk.ViewState(latitude=0, longitude=0, zoom=1),
    tooltip={"html": "<b>Name:</b> {name}", "style": {"color": "white"}})

Once the v9 alpha is released I will create a PR with the updates

@Jesus89 Jesus89 added this to the v9.0 milestone Feb 26, 2024
@donmccurdy
Copy link
Collaborator

@Jesus89 I believe all the required changes are now implemented by #8577, but I did want to mention a few differences in the PR, compared to what you've described above:

  1. I've included support for H3TileLayer and QuadbinTileLayer. I'm not sure what the get_hexagon and get_quadbin accessors mean in your comment above. Have I missed something in the PR?
  2. The PR uses the syntax access_token=carto_auth.get_access_token() instead of access_token=pdkc.get_access_token(carto_auth), hopefully that is fine and expected. :)

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

Successfully merging a pull request may close this issue.

2 participants