What are tiled vectors?

Ever wanted to display a really big GPS track or other vector data set in a browser-based map like Virtual Earth? If you've tried, you've probably seen the browser melt trying to process thousands of data points in JavaScript.

With Tiled Vectors, you package your vector data into constant-sized tiles, so that the browser only fetches just as much data as needs to fill one screenful. This is the same basic technique used to display logically-enormous raster images, which you can generate with MapCruncher. Here, however, the data is transmitted as vector data all the way to the client, so you can attach JavaScript behavior to the vectors.

In this demo, Virtual Earth shows a polyline data set with 50,000 segments in it, with constant-time performance. Notice that the status line "showing n vectors": n will never grow beyond a small constant (200 times the number of tiles visible on your display). There's no hard limit to the total number of segments in the input data set; we've displayed the 60 million segment Tiger line data set the same way.

How it works

First, an offline preprocessor prepares the data set by summarizing it and chopping it into tiles. As the map is zoomed and panned, the JavaScript code fetches the tiled data on demand, and each tile-sized vector list as a Virtual Earth ShapeLayer. When a tile goes off-screen, the corresponding ShapeLayer is deleted.

The data on the server is divided up into exactly the same geographic regions ("tiles") that the raster image is divided into. But instead of raster images, the server sends the client a JavaScript file containing first-class JavaScript objects. In this demo, those objects are a VEShapeLayer, and can be programmed to enjoy the interactive functionality of any other VE object.

How can I try this with my own data set?

This demo is available under MSR's source code license:

The python script GpxToTiles processes a .gpx file containing tracks (waypoints are ignored) into a series of tiles containing polylines. As it runs, it emits lines telling how much of the segment budget is used by the median and 95th-percentile tiles in each zoom level. Once you find most tiles aren't spending the whole budget, that's probably as far as you need to render.

You'll need to get your data into .gpx format. If it's not already, you can write a script that uses the GpxEmitter to convert from some other format.

The code currently supports only polylines; not filled polygons or points. Changes required:

GpxToTiles processes all the vectors in memory. If you have a really big data set (such as the 60-million-segment Tiger data), you'll need to process it out-of-core. Here's one approach:

By the time you get to a data set this big, you'll probably also want to improve and/or specialize the summarization used in GpxToTiles.

How else could this problem be solved?

Another way to display large data sets is to render them into rasters using MapCruncher. This approach works, and can produce very pretty representations, since clients can handle very complicated raster image tiles easily. However, rasters have no interactivity: users can't click on a line or point and get a pop-up, for example.

Recent releases of Virtual Earth can handle quite large data sets natively on the client. However, passing the entire data set to JavaScript will always cause at least a startup delay for large data sets, since the data must be transmitted and parsed by the client before display can begin.

In some situations, tiled vectors offer the best of both worlds, plus exposes new benefits:

Contact

This demo and the tiled-vector architecture was developed by the folks in Microsoft Research that brought you MapCruncher: .

Demo limitations

Why do the states look chunky when zoomed out? My summarization algorithm is pretty simplistic, and I'm using a limited budget of 800 segments per tile for this demo. You can apply the same client-side code, and use a more sophisticated preprocessing and summarization step to spend your segment budget more effectively.