Visualizing geographic data with the WebGL Globe
By Doug
Fritz of the Google Data Arts TeamToday we're sharing a new
Chrome Experiment called the
WebGL
Globe. It’s a simple, open visualization platform for geographic data that runs in
WebGL-enabled browsers like Google Chrome. The globe below shows
world population, and we’ve created
another globe showing
Google search
traffic.
The primary challenge of this project was
figuring out how to draw several thousand 3D data spikes as quickly and smoothly as possible.
To do this, we turned to
Three.js, a
JavaScript library for building lightweight 3D graphics. For each data point, we generate a
cube with five faces – the bottom face, which touches the globe, is removed to improve
performance. We then stretch the cube relative to the data value and position it based on
latitude and longitude. Finally, we merge all of the cubes into a single geometry to make it
more efficient to draw.
The second challenge of the project was
animating the globe – we wanted it to be fun for the user to manipulate. Thanks to
WebGL, we’re able to display thousands
of moving points at high frame rates by using the user’s graphics processing unit (
GPU) for 3D computations. Each state of
the globe has its own geometry and we morph between them with a vertex shader, saving precious
CPU resources. Additionally, to make the globe look nice, we took advantage of the
possibilities of
GLSL and created
two fragment shaders, one to simulate the atmosphere and another to simulate frontal
illumination of the planet.
Now that we’ve released the globe, we’re
hoping that developers like you will create your own. What data will you show on it? If you’re
feeling inclined, you can learn more about the data format (represented in
JSON) and
get the code here. If you create your own
globe, please also consider
sharing a link with us --
at some point in the future, we hope to post a list of interesting globes that have been
submitted.
UPDATE 6:16 PM: Fixed link to the code in last
paragraph.
Doug Fritz is a creative programmer in
Google's San Francisco office. Doug says he likes "simplifying the complex and complexifing
the simple, because in reality it's all somewhere in the middle".Posted by Scott Knaster,
Editor