Data Analysis with Vector Tiles I'm going to talk about the possibility of doing interactive data analysis in the browser.
Ways to do in-browser, interactive analysis: Two great, well-established answers: (1) just use GeoJSON, or (2) offload some of it to something like a PostGIS backend.
Ways to do in-browser, interactive analysis: Plain GeoJSON is great, but it's size-limited.
Ways to do in-browser, interactive analysis: If there's too much data for that, a natural answer is to use PostGIS on the backend to dynamically serve up the data you need. The downside here is complexity: you have the extra overhead of setting up and maintaining a server. Also, this approach means you'll need a round-trip to the server for each user interaction, or else a bunch of extra logic to pre-fetch data as the map moves.
These analysis problems are very similar to rendering problems. These are the same problems faced when trying to render in the browser, and this is exactly what VT's were designed to solve for. Why not piggyback on this for data analysis, too?
Example a. The squares here are colored based on OSM road density. I'll explain how they're built later. b. The data in the tooltip is coming from the same underlying vector tile source that's being used to render it. c. (Draw polygon, move it around) Using a little plugin based mostly on Turf.js d. (Zoom out, do it again) Here's the "scale-independence" that vector tiles really help with: same thing, but over much larger area.
How:
Building the Vector Tiles This is definitely the most challenging part. Typical strategy, simplifying and dropping features, works great for *rendering*: why keep the data around at zoom levels where you can't even see it? This is what existing tools like Mapbox Studio and tippecanoe are designed for. But doesn't work for us if we want to do stuff with the numbers. Instead, we went for this grid approach: thus the grid-based approach you just saw.
Building the Vector Tiles: vt-grid
// run over each "raw" input feature
function aggregate (sum, feature) {
  if (feature.properties.highway) {
    return sum + lineDistance(feature)
  } else {
    return sum
  }
}
// apply to each grid cell output
function postAggregate (cell) {
  var length = cell.properties.roads_km
  return length / area(cell.geometry)
}
vt-grid is a little node module we built to help create tilesets Start with your "raw" features, probably at a very high zoom level; apply simple functions like this over those raw features to build a grid of aggregated data. Uses 'tile-reduce' (which you can hear much more about tomorrow) and 'tippecanoe' (OPTIONAL) Btw, this is simplified: my actual script used "cheap-ruler" for "lineDistance" and "area".
Frontend: Mapbox GL JS plugins
Data-Driven Style 'polyfill'
mapbox-gl-datadriven
View/Summarize Data
mapbox-gl-datascope
Questions? What's Missing? What's Next?
https://github.com