Change Layer API - Dataframe / Common Source
See original GitHub issueRelated with https://github.com/CartoDB/cartoframes/issues/615
Context
This issue focuses on continuing the previous issue about the Layer API (https://github.com/CartoDB/cartoframes/issues/615)
The first part of changing the Layer API was to use a single Layer class instead of having different Layer types, and create different sources that are equivalent to CARTO VL sources for consistency.
In this second step, we aim to use the Dataframe
class to have the possibility of generating sources in the notebook and pass it to the Layer.
From this comment by @oleurud:
The user wants to make things over the data (using Pandas) and then render a map with the data. To do this, we have 2 options:
- OPTION 1: the user makes things over the data (pandas or other ways), then upload the data to CARTO and finally use the VL way to render the map. To do this, if I am not wrong, we don’t have to integrate anything between backend and frontend.
- OPTION 2: the user makes things over the data (pandas) and then the user has a way to send the pandas.DataFrame to VL. To do this, we have to integrate backend and frontend (find a way to send a pandas.DataFrames to VL). The yesterday proposal was talking about this case, because I think having a full local way to render a map is powerful. I want to talk about it with @javitonino & @alrocar. But of course, any feedback is welcome.
The first one is already implemented by frontend team. So the objective here is to find the best way to make possible the second one (if it makes sense)
Other questions / ToDo:
- Use a Layer as a stand-alone map a la layer.map() (from this comment)
- Discuss: Should we sort the layers?
Update
We have finally decided to simplify the API. New examples are contained in /examples/debug/API
. This is an example of the usage:
from cartoframes import Context, set_default_context
from cartoframes.vis import Map, Layer
context = Context(
base_url='https://cartovl.carto.com/',
api_key='default_public'
)
set_default_context(context)
# Table name
Map(Layer('populated_places', 'color: blue'))
# SQL query
Map(Layer('SELECT * FROM populated_places LIMIT 10'))
# GeoJSON (object, features, feature, geometry, filename, GDF)
Map(Layer(geojson))
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (9 by maintainers)
Top GitHub Comments
I have implemented here the idea of the connection between Source and Dataset, and also added some examples with the approach for the API: https://github.com/CartoDB/cartoframes/pull/662.
I included a PoC encoding the GeoJSON in base64 in the current PR: https://github.com/CartoDB/cartoframes/pull/626/commits/dc83d9297074288860cafab30b519dac055e9ecb