CARTO User Manual

CARTO User Manual

Add source

When you open a map, the Layers tab will appear on the left side panel. There you can add data as layers to the map by clicking on “Add source from”, where you can access the contents from your existing data warehouse connections. If you haven’t added a data layer to the map yet, you will see the following page:

Add source to your map

Add source from a connection

From the Layers tab, go to the Sources panel and click on Add source from…. A new dialog screen will open allowing you to select a table or a tileset from on of your connections. Insert the Fully Qualified Table or the Tileset Name and click Add source.

Add source select a connection

Add source select a table

Once the process is finished, the table or tileset is included in the Builder map as a new layer. The map displays the basemap and the new layer on top. You can add additional layers, or start applying styling and analysis features.

Map created

Once you have added your datasets to the map, you can visualize the data table. Click on the three dots icon, select Show data table and your dataset table will be displayed.

Map source options view data table

By clicking the tree dots icon the Column Context menu will reveal additional options such as: Sort on this column, ascending or descending, Pin the column so you can freeze it in the first position, and copy column data.

Map table column

Once you have added your datasets to the map, you can always add a new layer or delete the source. Click on the three dots icon and select Add layer or Delete source.

Map source options delete source

Add source from a custom query

Go to Sources and click Add source from…. A new dialog screen will open allowing you to create your own query or run a SQL analysis to data on your connection. Select an option and click Add source.

Add source custom query

Add source analysis query

Once the process is finished, the SQL console appears in the Builder interface, where you can type your query and then click Run. Please make sure to use Fully Qualified Table names.

Map sql console

In this example we are going to use a table accessible via a BigQuery connection. The BigQuery table is included in the Builder map tool as a new layer. You can add additional layers, or apply styling and analysis features.

Map add query

Custom queries using the Analytics Toolbox

You can also use the Analytics Toolbox functions in your custom SQL queries. For example, you can perform a simple clustering using the ST_CLUSTERKMEANS function by running this query from your CARTO Data Warehouse connection:

1
2
3
4
5
6
7
with clustered_points AS
(
    SELECT `carto-un`.clustering.ST_CLUSTERKMEANS(ARRAY_AGG(geom ignore nulls), 6) AS cluster_arr
    FROM carto-demo-data.demo_tables.sample_customer_home_locations
)

SELECT cluster_element.cluster, cluster_element.geom AS geom FROM clustered_points, UNNEST(cluster_arr) AS cluster_element

This query computes five clusters from the points of the sample_customer_home_locations table. As a result, each point is assigned a cluster ID. By styling the layer by this cluster attribute, we get the following result:

Map add query

To learn more, please visit the Documentation page of the Analytics Toolbox for BigQuery (also valid for the CARTO Data Warehouse) and Analytics Toolbox for Snowflake.