Session Info

Title: Managing and Visualizing your Geospatial Data with Fusion Tables

Hashtags: #io2011 #Geo

Feedback: http://goo.gl/79Lvg

Managing and Visualizing your
Geospatial Data with Fusion Tables

Kathryn Hurley, James McGill
Guest Speaker: Simon Rogers, Guardian Datablog
May 10, 2011

Agenda

Intro to Fusion Tables

Intro to Fusion Tables

A database in the cloud used to store and visualize your data

*

* Source: Guardian "Deprivation mapped: how you show the poorest (and richest) places in England"

Another example visualization - Google Visualization API

Using Google Chart Tools to Create Interactive Dashboards
May 10, 02:30PM – 03:30PM / Room 1

Quick Demo

Quick Demo

Building an Application with Fusion Tables

Application ideas..

Application workflow - Mapping Newpapers Around the World

API Details

SQL API Details

Sample Code*

query = 'CREATE TABLE newspapers (name: STRING, location: LOCATION, link: STRING)'
  
headers = {
  'Content-Type': 'application/x-www-form-urlencoded',
}

serv_req = urllib2.Request(
  url='https://www.google.com/fusiontables/api/query',
  data=urllib.urlencode({'sql': query}),
  headers=headers)

//returns tableid if successful
tableid = urllib2.urlopen(serv_req)

*Authorization steps omitted

API Demo

New Features

New API Features!








Now launching to trusted testers

How to be a trusted tester

Sign up here:

fusion-tables-api-trusted-testers@googlegroups.com

How do these new features work?

{
  ...
  "tableId": 12345,
  "markerOptions": {
    "iconName": "small-blue"
  }
  ...
}
      	

Why is this awesome?

Trusted Testers needed!

Sign up here:

fusion-tables-api-trusted-testers@googlegroups.com

Google Maps API & Fusion Tables

Mapping your data

var layer = new FusionTablesLayer({
  select: 'column',
  from: 200949,
});
layer.setMap(map);

Adding conditions

var layer = new FusionTablesLayer({
  select: 'column',
  from: 12345,
  where: "Age > 50"
}); 



Why use FusionTablesLayer?

Default behaviour

Customizing behaviour

var layer = new FusionTablesLayer({
  query: {
    select: 'column',
    from: 12345,
  },
  suppressInfoWindows: true
});

google.maps.event.addListener(layer, 'click', doSomethingCool);

Customizing behaviour

Styled Maps

Performance

Tiled Rendering

Add a little Style

Styling syntax

var layer = new FusionTablesLayer({
  query: {
    select: 'geometry',
    from: 815230,
  },
  styles: [{
    polygonOptions: {
      fillColor: "#00FF00"
    }
  }]
}); 

Restricting styles

var layer = new FusionTablesLayer({
  ...
    {
      where: "bird_species > 300",
      polygonOptions: {
        fillColor: "#0000FF"
      }
    }]
}); 

Cascading styles

var layer = new FusionTablesLayer({
  ...
    {
      where: "population > 5", /* People per km² */
      polygonOptions: {
        fillOpacity: 1.0
      }
    }]
}); 

Dynamically updating

  var newStyle = {
    where: 'plant_species > 1000',
    polygonOptions: {
      fillColor: "#FF0000"
    }
  };

  function updateStyle() {
    // Replace one existing style.
    var oldStyles = layer.get('styles'); 
    oldStyles[1] = newStyle; 
    layer.set('style', oldStyles);
  } 

Dynamically updating II

google.maps.event.addDomListener(
  document.getElementById('some_button'),
  'click',
   updateStyle);

Pitfalls

bird_species > 100bird_species < 100 = ∅.
var layer = new FusionTablesLayer({
  query: {
    select: 'column',
    from: 12345,
    where: "bird_species < 100"
  },
  styles: [{
    where: "bird_species > 100",
    polyline: {
      strokeColor: "#FF0000",
    }
  }]
}); 

Other styles

Worth noting



Simon Rogers
Editor, Guardian Datablog

Summary

Links

Questions?