Thursday, November 11, 2010

Spatial Queries Added to Fusion Tables!

Google Fusion Tables now offers spatial queries. Using spatial queries, developers can find all features that are located within a given distance of a specified location, find all features that are located within a given bounding box, and find a given number of features closest to a location.

Bounding box queries take the form of:

SELECT * FROM 297050 WHERE ST_INTERSECTS(Address, RECTANGLE(LATLNG(37.2, -122.3), LATLNG(37.6, -121.9)))

Where 297050 is the key for your Fusion Table and the LATLNG coordinates represent the bounding box.

If you want to see how you can add buttons to a Google Fusion map that will load a spatial query I've created a quick example, World Crime Rates. This map shows world crime and homicide rates. The map has queries to view only countries with crime rates over certain figures. It also has two spatial queries - one to show results only from Europe and one that shows results from the Americas. The two spatial queries use the bounding box function.

You can learn more about the new spatial query offering in Fusion Tables in the Fusion Tables documentation.

Via: Search your geo data using spatial queries from Fusion Tables!



Tom Wayson said...

Any idea if you can query across two tables? Example: query all the points in one table that intersect a polygon (i.e. city boundary imported from another table)?


Keir Clarke said...

Interesting idea. You might need to use the Fusion Tables API itself to do that.

Keir Clarke said...

@Tom - the Fusion Tables Users Group would probably be the best place to get a definitive answer to your question.

BabyBoo said...

From researching spatial queries in Fusion Tables, it seems you can only query using a circle or rectangle. I too would like to be able to query using polygons.

Does anyone know if there are plans to implement query by polygon in Fusion Tables?