satellite view

Richer data visualization on Google Maps Platform using deck gl.

Richer data visualization on Google Maps Platform using deck gl.

Try Google Maps Platform.

Richer data visualization
Examples of different visualizations made possible by the deck.gl/WebGL Overlay View integration.

Unlock access to real world data and insights with a monthly $200:. Google Maps Platform credit. GET STARTED

Today at Google Cloud Next. We are showcasing the release of the newest open source data visualization library deck.gl version 8.6. Thanks to a close collaboration between our friends at the location intelligence platform CARTO. The vis.gl Technical Steering Committee (TSC), and teams from Google Maps Platform and Google Cloud. This release adds deep integration of deck.gl with the WebGL Overlay View feature of the Maps JavaScript API. Now you can take advantage of the wide variety of beautiful. Insightful 2D and 3D visualizations offered by deck.gl to create a new level of mapping experiences with your data.

These new types of visualizations can be used to address any geospatial use case. To show the powerful capabilities of deck.gl with the Maps JavaScript API. The team at CARTO created an example app that visualizes a variety of data sources that show the potential for electrification of truck fleets in Texas. This example showcases how CARTO uses deck.gl and our WebGL-powered maps features tools to bring:. Texas’ area and population sizes to life. Using fully interactive map visualizations.

Richer data visualization
CARTO’s story map uses deck.gl to visualize the potential for electrification of truck fleets in Texas.

How does deck.gl work with the Maps JavaScript API?.

Deck.gl has supported the raster basemap offered by the Maps JavaScript API for a while. This new release adds support for the vector basemap in interleaved mode. This means that with deck.gl:. Google’s vector map can now be mixed with data layers. Providing a pixel perfect composition where labels. 3D. And other content is respected and rendered perfectly with depth and occlusion.

Under the hood this means that the vector basemap and deck.gl share the same WebGL rendering context. Increasing the performance. And flexibility of visualizations rendered on the map. In effect, instead of the visualizations of deck.gl being rendered on the map, they are now rendered as part of the map. Sharing this WebGL context is not easy. So our team and the CARTO team have partnered to provide support as both libraries evolve.

Let’s take a look at an example.

In the following code. We are loading data from a CSV file using the open source library loaders.gl. Creating a Hexagon deck.gl visualization layer. Creating an overlay for Google Maps Platform. And finally adding it to the map.

Richer data visualization
Code for a simple deck.gl Hexagon Layer visualization.
Richer data visualization
The Hexagon Layer visualization from the code above, applied to the map of the United Kingdom.

Advanced visualization capabilities.

Deck.gl offers a very flexible framework for creating or utilizing existing visualizations. Check out the examples on the deck.gl website and CARTO’s gallery of demos to get some inspiration.

Richer data visualization
Check out the gallery of demos.

With the flexibility of deck.gl. Of course you can go quite a long way. As showcased in CARTO’s Texas demo. Let’s take a look at some of the main visualizations.

Hexagon Layer

The Hexagon layer is useful for visualizing aggregated data. You can define the colors or the height of the hexagons. Using a property such as population. In this example. You can see how the population of Texas is concentrated in a few large urban areas.

Map Large datasets using Vector Tiles

When visualizing large datasets. Like in the case of the power line visualizations. You are going to need to load the data progressively in tiles. Deck.gl has different pre created layers like MVTLayer. TileLayer or  Tile3DLayer.

Richer data visualization
Electrical transmission lines across Texas, shown using a Tile3DLayer visualization.

In this map we are visualizing an open dataset of around 70MB of electric power lines. Using the CartoLayer on deck.gl. This visualization loads the data in small vector tiles of less than 512kb.

Animations and rich cartography

In addition to cartographic capabilities. Animation features allow for a much richer set of visualizations. And a seamless user experience. The example below shows Texas’ renewable energy sources.

Richer data visualization on Google Maps Platform using deck gl

Animating trips and 3D

Animating trips is one of the most popular deck.gl visualizations. And because of the interleaving support. Those trips respect buildings and all other Google Maps Platform features.

Check out the code here.

Try it out

To get started, take a look at some of the demos of deckgl + Google Maps Platform. Then head to deck.gl website to learn more in advance on how to customize the layers or even create your own ones. Finally the entire source code for the Texas demo is also freely available.

We hope you have fun mixing deck.gl and Google Maps Platform we can’t wait to see what interesting visualizations you build. For more information on CARTO. Getting a free account. And overlaying data from BigQuery, visit the CARTO website.
For more information on Google Maps Platform. visit our website.

Source: medium.com

Earthtopomaps.com

Richer data visualization on Google Maps Platform using deck gl

Deck.gl has supported the raster basemap offered by the Maps JavaScript API for a while.

In effect, instead of the visualizations of deck.gl being rendered on the map, they are now rendered as part of the map.

So our team and the CARTO team have partnered to provide support as both libraries evolve.

In the following code. And finally adding it to the map. Of course you can go quite a long way.

Using a property such as population. When visualizing large datasets.

This visualization loads the data in small vector tiles of less than 512kb.

And because of the interleaving support.

Richer data visualization on Google Maps Platform using deck gl.

Deck.gl has supported the raster basemap offered by the Maps JavaScript API for a while.

In effect, instead of the visualizations of deck.gl being rendered on the map, they are now rendered as part of the map.

So our team and the CARTO team have partnered to provide support as both libraries evolve.

In the following code. And finally adding it to the map. Of course you can go quite a long way.

Using a property such as population. When visualizing large datasets.

This visualization loads the data in small vector tiles of less than 512kb.

And because of the interleaving support.

Deck.gl has supported the raster basemap offered by the Maps JavaScript API for a while.

In effect, instead of the visualizations of deck.gl being rendered on the map, they are now rendered as part of the map.

So our team and the CARTO team have partnered to provide support as both libraries evolve.

In the following code. And finally adding it to the map. Of course you can go quite a long way.

Using a property such as population. When visualizing large datasets.

Using a property such as population. When visualizing large datasets.

This visualization loads the data in small vector tiles of less than 512kb.

And because of the interleaving support.

Richer data visualization on Google Maps Platform using deck gl.

Carto platform enables advanced data visualizations with Google Maps

CARTO platform enables advanced data visualizations with Google Maps

Try Google Maps Platform

Unlock access to real world data and insights with a monthly $200 Google Maps Platform credit. GET STARTED

Editor’s note: Today’s blog post is from Alberto Asuero. CTO of CARTO.  The location intelligence platform. Today he shares more details about the source of the data for advanced data visualizations created with Google Maps Platform. And deck.gl and how the CARTO platform enables this workflow.

During Google Cloud Next in October, the Google team announced the newest release of the deck.gl visualization library. Thanks to a collaboration with our geospatial company CARTO and the vis.gl Technical Steering Committee (TSC). The deck.gl release includes a deep integration with the new WebGL-powered features in the Maps JavaScript API that allows deck.gl to render 2D and 3D visualizations directly on the Google basemap. 

Our team built an example app that visualizes a variety of data sources that show the potential for electrification of truck fleets in Texas.

This app showcases the different types of advanced data visualizations that can be created with Google Maps Platform and deck.gl. Today. I want to share more details about the source of the data for these visualizations and how the CARTO platform enables this workflow. 
Google Cloud provides a strong serverless data warehousing solution, BigQuery, with support for geospatial queries. When you are dealing with spatial data. Creating maps to explore and visualize these datasets is an important and common need. The CARTO Spatial Extension for BigQuery provides an easy way to create connections to the data warehouse, design a map with data coming from BigQuery tables. And then add these visualizations to a web app using deck.gl.

carto platform enables data
An example of retrieving a Map ID from CARTO Builder
carto platform enables data
Different custom styles can be applied to the map directly in CARTO Builder

Making a simple map

To create a simple map using the CARTO platform, you can sign up for a trial account. Once you have signed in. You can set up a connection to your BigQuery instance using a service account. Then. You can go to the Data Explorer. And browse the available datasets to find the table you want to use as the datasource in your map. For more information. Check out the CARTO documentation.

carto platform enables data
CARTO  Builder’s Data Explorer allows you to preview different geospatial datasets

CARTO platform enables data visualizations Google Maps

To create a visualization of power transmission lines in Texas. You can start with the Texas state boundary to provide some context. In the Data Explorer. You can preview the table and click the “Create map” button in the top-right corner to start designing your visualization.

Using the CARTO Builder map making tool. Select one of the available Google vector basemap styles and customize the layer style.

carto platform enables data
The result of an executed geospatial query displayed in CARTO Builder

You can visualize tables. And the results from queries executed in the data warehouse. Which is a powerful feature because you can also execute spatial analysis functions using SQL. Including those from the CARTO Analytics Toolbox. In this case. You can intersect the lines in the table containing all the U.S. transmission lines within the Texas boundary. Click on the “Add source from…” button and select the “Custom Query (SQL)” option to add the following query:.

  SELECT * 
FROM cartobq.nexus_demo.transmission_lines
WHERE ST_INTERSECTS(
  geometry, 
  (SELECT geom FROM cartobq.nexus_demo.texas_boundary_simplified)
);
carto platform enables data
An example of a geospatial query being executed in CARTO Builder

Click the “Run” button, and the query is executed in BigQuery. The results are sent back to the Builder tool. Perform some style customizations in the new layer. And your map is ready.

carto platform enables data
Results are automatically visualized when they are returned from BigQuery

Before adding the map to the Google Maps Platform application, you’ll need to make it public. Click on the “Share” button and select the “Developers”. Tab to copy the map ID.

carto platform enables data
Generate a Map ID for use with Google Maps Platform web and mobile SDKs from the share menu in CARTO Building

Now, you can add the visualization into your Google Maps Platform application, which is as easy as adding these four lines of code:

  const cartoMapId = 'b502bf53-877d-4e89-b5ad-71982cac431d';
deck.carto.fetchMap({cartoMapId}).then(({layers}) => {
  const overlay = new deck.GoogleMapsOverlay({layers});
  overlay.setMap(map);
});

You can use the map ID copied from CARTO Builder to call the fetchMap function. This function connects to the platform. And retrieves all the information needed for the visualization, including a collection of deck.gl layers with all the styling properties you’ve specified. Create an instance of the deck.gl  GoogleMapsOverlay with this collection of layers and add it to the map.
You can see the full example in this fiddle.

carto platform enables data
Full example available in JSFiddle

Visualizing very large datasets

One of the main features of BigQuery is the ability to scale processing to massive datasets. With the CARTO platform. You can also visualize very large datasets using tilesets. An optimized data structure containing pre-generated vector tiles for fast visualization. Tilesets are generated within BigQuery using the Analytics Toolbox functions in a parallelized process that can handle billions of points.

For example, you can create a visualization using tilesets with the whole dataset of transmission lines for the U.S.. More than 100MB of geometries. 

The issue with these large datasets is that they do not fit in memory all at once, so you need to split them into tiles for them to be rendered progressively. CARTO takes care of this. Allowing you to create tilesets directly in BigQuery or dynamically generate them on the fly.

carto platform enables data
A tileset generated in BigQuery and displayed in CARTO Builder

This method for data loading in maps can scale as much as needed; for example, take a look at this 17 billion point visualization of vessel data.

CARTO platform enables data visualizations Google Maps

What about live data?

BigQuery supports streaming data that is continuously updated. In these scenarios, you want to be able to update your visualization at regular intervals, as the data changes. It’s easy to update this visualization using deck.gl. You just need to set the autoRefresh parameter to true when fetching the map and specify the function you want to execute when new data is downloaded:

  const {layers} = await deck.carto.fetchMap({
  cartoMapId,
  autoRefresh: true,
  onNewData: (parsedMap) => { … }
});

You can add points to a table with an INSERT function on the BigQuery console and see the data updated on the map in real time.

carto platform enables data
Datasets in BigQuery can be updated on the fly on visualized with CARTO

CARTO platform enables data visualizations Google Maps

Going further

In addition to the simple ways to create visualizations shown above, deck.gl has the flexibility to create a wide variety of visualizations. The CARTO platform provides you with the functionality to access data from your data warehouse and create these data visualizations with advanced cartographic capabilities, but you can extend it and go beyond that using any of the advanced visualizations available in the deck.gl layer catalog.
There are two additional options that give you more control over the deck.gl code. The first one is to use the CartoLayer directly without fetchMap. You’ll need to indicate the connection to use from the CARTO platform and the data source type and name or query. Then we can specify the styling properties.

  const overlay = new deck.GoogleMapsOverlay({
  layers: [
    new deck.carto.CartoLayer({
      connection: 'bqconn',
      type: deck.carto.MAP_TYPES.TABLE,
      data: `cartobq.public_account.retail_stores`,
      getFillColor: [238, 77, 90],
      pointRadiusMinPixels: 6,
    }),
  ],
});

The second option is to use the fetchLayerData function that allows you to have more control over the format used for data transfer between BigQuery. And your application and can be used with advanced visualizations that require an specific data format like ArcLayerH3HexagonLayer or TripsLayer.

  deck.carto.fetchLayerData({
  type: deck.carto.MAP_TYPES.TABLE,
  source: `cartobq.geo_for_good_meetup.texas_pop_h3`,
  connection: 'bqconn',
  format: deck.carto.FORMATS.JSON,
  credentials: {
     accessToken: 'eyJhbGciOiJIUzI1NiJ9.eyJhIjoiYWNfbHFlM3p3Z3UiLCJqdGkiOiI1YjI0OWE2ZCJ9.Y7zB30NJFzq5fPv8W5nkoH5lPXFWQP0uywDtqUg8y8c'
   }
 }).then(({data}) => {
  const layers= [
    new deck.H3HexagonLayer({
      id: 'h3-hexagon-layer',
      data,
      extruded: true,
      getHexagon: d => d.h3,
      getFillColor: [182, 0, 119, 150],
      getElevation: d => d.pop,
      elevationScale: 2.5,
      parameters: {
        blendFunc: [luma.GL.SRC_ALPHA, luma.GL.DST_ALPHA],
        blendEquation: luma.GL.FUNC_ADD
      }
    })
  ];
  const overlay = new deck.GoogleMapsOverlay({layers});
  overlay.setMap(map);
 });

For complete code using both options. Take a look at these examples.

carto platform enables data
Example of using the deck.gl Hexagon Layer visualization with Google Maps Platform and CARTO

Learn more

You can access demos and documentation on the deck.gl docs website and the CARTO Documentation Center. If you have questions, you can ping the CARTO team on the CARTO Users Slack workspace.

https://earthtopomaps.com/ 



For more information on Google Maps Platform, visit the Google Maps Platform website

You just need to set the autoRefresh parameter to true when fetching the map and specify the function you want to execute when new data is downloaded:

Translate »
view satellite
%d bloggers like this: