This example illustrate how to publish a visualization using a GeoDataFrame.
Read more about Maps API Keys: https://carto.com/developers/auth-api/guides/types-of-API-Keys/
Note: You'll need CARTO Account credentials to reproduce this example.
from cartoframes.auth import set_default_credentials
set_default_credentials('creds.json')
from geopandas import read_file
gdf = read_file('http://libs.cartocdn.com/cartoframes/files/sustainable_palm_oil_production_mills.geojson')
from cartoframes.viz import Map, Layer
map_viz = Map(Layer(gdf))
map_viz.publish(
name='map_gdf',
password='1234',
if_exists='replace')
{'id': 'e1ee8600-de8d-48a0-b650-16d050507963', 'url': 'https://cartoframes-org.carto.com/u/cartoframes/kuviz/e1ee8600-de8d-48a0-b650-16d050507963', 'name': 'map_gdf', 'privacy': 'password'}
The performance of visualizations can be affected by using large GeoDataFrames. There is also a size limit of 10MB per visualization published. Our recommendation in these cases is to upload the data to a table in CARTO, and use the table as the source in the Layer.
from cartoframes import to_carto
to_carto(gdf, 'table_name', if_exists='replace')
Success! Data uploaded to table "table_name" correctly
'table_name'
map_viz = Map(Layer('table_name'))
map_viz.publish(
name='map_table',
password='1234',
if_exists='replace')
The map has been published. The "cartoframes_0a8a065b2cc026c5c33ee3dc269afcf1" Maps API key with value "YTAEiju-Utii8mgtERiEkA" is being used for the datasets: "table_name". You can manage your API keys on your account.
{'id': 'd92b9d44-f292-4bdd-8715-56368d8e57ee', 'url': 'https://cartoframes-org.carto.com/u/cartoframes/kuviz/d92b9d44-f292-4bdd-8715-56368d8e57ee', 'name': 'map_table', 'privacy': 'password'}