New CARTO Boundaries for faster visualizations in spatial apps

Summary

Announcing CARTO Boundaries for faster spatial app visualizations! Join data with pre-generated vector tilesets for efficient processing. 

This post may describe functionality for an old version of CARTO. Find out about the latest and cloud-native version here.
New CARTO Boundaries for faster visualizations in spatial apps

At CARTO we are committed to delivering the most advanced and complete cloud-native spatial analytics platform. CARTO enables geospatial analysts, data scientists and developers to build the most performant spatial analysis and applications natively in their cloud data warehouses.

Many of these applications - covering use-cases such as territory and site planning, market analysis & geofencing - still rely on analyzing and visualizing data based on administrative boundaries such as census block groups, postal codes, and counties. These are key for helping map users navigate and understand locations. However, with ever growing volumes of data and the need for large-scale geospatial analysis, processing and rendering large volumes of complex boundary geometries poses important challenges when developing spatial applications.

Today, we’re excited to announce the availability in public preview of CARTO Boundaries, a new feature that enables faster data visualizations of geospatial big data based on official administrative, postal and statistical boundaries.

CARTO Boundaries is a new type of visualization, included in the CARTO module of the recently released deck.gl v9, that unlocks a whole new performance dimension for large scale spatial visualizations. By separating the data - which can be filtered or aggregated dynamically - from the static boundary geometries; we not only accelerate map visualizations, but also offer a simplified architecture as geometries do not need to be served on every request to the data warehouse.

CARTO Boundaries in a nutshell

Developers using CARTO and deck.gl can leverage this new type of visualization that offers the possibility to join client-side the data table with a pre-generated vector tileset. This tileset includes the boundary geometries, removing the need for you to process heavy geography/geometry data in every query. Because both the data and geometries share a matching column with an ID (e.g. the 5-digit postal code), CARTO is able to perform operations without using the actual geometry data, incorporating the geometries later to visualize the result of the operation on a map. This maximizes performance exponentially and simplifies the architecture of the application.

You can see how this works in the snippet below:

   
function render() {

  const querySource = boundaryQuerySource({
    ...cartoConfig,
    tilesetTableName: 'carto-boundaries.us.tileset_usa_zipcode_v1',
    propertiesSqlQuery: `SELECT geoid, AVG(avg_ticket) as avg_ticket
        FROM daily_usa_uszc_2015 
          WHERE timeinstant between @start and @finish
          and industry=@industry and segment='o' and geo_type='m'
          group by geoid`,
    matchingColumn: 'geoid',
    queryParameters: {
      start: '2023-01-01',
      finish: '2023-03-31',
      industry: 'ret'
    }
  });

  const layers = [
    new VectorTileLayer({
      id: 'boundary-query',
      data: querySource,
      pickable: true,
      getFillColor: (d) => {
        const avg_ticket = Number(d.properties.avg_ticket);
        if (avg_ticket 	< 25) return [247, 254, 174];
        if (avg_ticket 	< 50) return [183, 230, 165];
        if (avg_ticket 	< 75) return [124, 203, 162];
        if (avg_ticket 	< 100) return [70, 174, 160];
        if (avg_ticket 	< 200) return [8, 144, 153]
        return [0, 113, 139];
      },
      getLineWidth: 1,
      lineWidthUnits: 'pixels',
      
    })
  ]
  deck.setProps({layers});
}
   

As part of this release we have also made an initial collection of pre-generated vector tilesets available. These include administrative, postal and statistical boundaries in 5 different countries (USA, UK, Canada, Spain and Mexico) that are ready to be used in your applications on top of Google BigQuery and Snowflake. In the next months we will be expanding this collection with more countries and types of boundaries.

You can check our collection of prepared boundaries and access sample code via our Boundaries Explorer (see below).

To use these boundaries in your application just select your data warehouse, region and then select Use this boundary in your app. You can then copy & paste the generated code into your application, as illustrated below.

A screenshot of the CARTO Boundary Explorer with generated code
Generating boundary code with the Boundaries Explorer

You can access these boundaries via:

  • Google BigQuery: in the carto-boundaries public project, which contains datasets on different regions that contain the boundaries.
  • Snowflake: we have made this public listing available in the Snowflake Data Marketplace.

Can’t find the boundaries you need? Check our Data Observatory!

If you don’t find the type of boundaries that you need in our collection, don’t panic! Our implementation is flexible so you can also leverage your own tilesets with custom boundaries. In our Data Observatory you can find over +500 digital boundaries that you can turn into pre-generated tilesets in exactly the same way as we’ve outlined above.

A screenshot of the CARTO Spatial Data Catalog
The CARTO Spatial Data Catalog

Check out the code below for an example of how to leverage “custom” boundaries.

   
CALL `carto-un`.carto.CREATE_SIMPLE_TILESET(
    '(SELECT geom AS geom, geoid FROM `carto-data.geographies.sub_carto_geography_usa_state_2019`)',
    '`your-project.your-dataset.states_boundaries_tileset_v1`',
    '''
    {
      "geom_column": "geom", 
      "calculate_geoids": true, 
      "zoom_min": 0, 
      "zoom_max": 6, 
      "properties": {
        "geoid": "String"
      }
    }
    '''
);

   

In order to convert the digital boundary data into pre-generated tilesets, CARTO offers tilers for each cloud data warehouse in our Analytics Toolbox.

All of these digital boundaries are available not just as pre-generated tilesets, but also as tables with the raw geometries. These can be used not only for visualization but also for geospatial analysis and data processing operations such as data enrichment and intersections - check out the CARTO Academy for tutorials to help with this!

Start building with CARTO Boundaries today

Want to start using CARTO Boundaries today? Explore our product documentation, and request a demo with one of our experts to learn how this powerful feature can help your organization scale your analytics!