Sql for Everything: GIS on the Web

37
SQL For Everything Geoprocessing and Cartography With PostGIS Bill Morris Geosprocket LLC

description

An overview of geoprocessing in its best web incarnation: PostGIS

Transcript of Sql for Everything: GIS on the Web

Page 1: Sql for Everything: GIS on the Web

SQL For Everything

Geoprocessing and Cartography With PostGIS

Bill Morris – Geosprocket LLC

Page 2: Sql for Everything: GIS on the Web

Speedy Background

• SQL = Structured Query Language

• Beloved/BeHated by Database Admins

• Runs Behind Nearly Everything

SQL For Everything - Bill Morris - Geosprocket LLC

Page 3: Sql for Everything: GIS on the Web

Ever Fired Up a Computer?

You’ve Used SQL.

SQL For Everything - Bill Morris - Geosprocket LLC

Page 4: Sql for Everything: GIS on the Web

So What’s PostGIS?

• A spatial extender for the PostgreSQL database system

• Free as in Speech, Free as in Beer

SQL For Everything - Bill Morris - Geosprocket LLC

Page 5: Sql for Everything: GIS on the Web

What’s Post-PostGIS?

• A parody on Twitter. Pay no mind.

SQL For Everything - Bill Morris - Geosprocket LLC

Page 6: Sql for Everything: GIS on the Web

What’s CartoDB?

• A PostGIS environment built for the web

• “Open-Source Fusion Tables”

• Build your own server: https://github.com/CartoDB/cartodb20

• Or get a hosted account: http://cartodb.com/

SQL For Everything - Bill Morris - Geosprocket LLC

Page 7: Sql for Everything: GIS on the Web

SQL For Everything - Bill Morris - Geosprocket LLC

Page 8: Sql for Everything: GIS on the Web

SQL For Everything - Bill Morris - Geosprocket LLC

Page 9: Sql for Everything: GIS on the Web

Back to SQL.

SQL For Everything - Bill Morris - Geosprocket LLC

Page 10: Sql for Everything: GIS on the Web

SQL as we know it

SQL For Everything - Bill Morris - Geosprocket LLC

Source: Chicago Crime Commission & Openstreetmap Contributors

Page 11: Sql for Everything: GIS on the Web

SELECT * FROM territory_all WHERE

“NAME” LIKE ‘Latin%’

SQL For Everything - Bill Morris - Geosprocket LLC

Source: Chicago Crime Commission & Openstreetmap Contributors

Page 12: Sql for Everything: GIS on the Web

SELECT * FROM territory_all WHERE

name LIKE ‘Latin%’

SQL For Everything - Bill Morris - Geosprocket LLC

Page 13: Sql for Everything: GIS on the Web

Geoprocessing as we know it

SQL For Everything - Bill Morris - Geosprocket LLC

Page 14: Sql for Everything: GIS on the Web

Geoprocessing in PostGIS

SQL For Everything - Bill Morris - Geosprocket LLC

SELECT ST_Whatever( geoprocess! )

Page 15: Sql for Everything: GIS on the Web

Geoprocessing in PostGIS

SQL For Everything - Bill Morris - Geosprocket LLC

Page 16: Sql for Everything: GIS on the Web

Buffer 500m

SQL For Everything - Bill Morris - Geosprocket LLC

Page 17: Sql for Everything: GIS on the Web

Buffer 500m from the points that fall on Ashland Ave

SQL For Everything - Bill Morris - Geosprocket LLC

Page 18: Sql for Everything: GIS on the Web

Append two layers of different geometry types

SQL For Everything - Bill Morris - Geosprocket LLC

Page 19: Sql for Everything: GIS on the Web

Geoprocessing Optimized

SQL For Everything - Bill Morris - Geosprocket LLC

…png?sql=…

Page 20: Sql for Everything: GIS on the Web

?

SQL For Everything - Bill Morris - Geosprocket LLC

Page 21: Sql for Everything: GIS on the Web

This is Familiar

SQL For Everything - Bill Morris - Geosprocket LLC

google.com?q=GIS

Page 22: Sql for Everything: GIS on the Web

SQL For Everything - Bill Morris - Geosprocket LLC

…png?sql=…

Page 23: Sql for Everything: GIS on the Web

http://2.tiles.cartocdn.com/geosprocket/tiles/vtparcels_burlington2002b/15/9714/11850.png

SQL For Everything - Bill Morris - Geosprocket LLC

Page 24: Sql for Everything: GIS on the Web

http://2.tiles.cartocdn.com/geosprocket/tiles/vtparcels_burlington2002b/15/9714/11850.png?sql=SELECT * FROM vtparcels_burlington2002b WHERE area>8000

SQL For Everything - Bill Morris - Geosprocket LLC

Page 26: Sql for Everything: GIS on the Web

Going off the Rails a Bit . . .

SQL For Everything - Bill Morris - Geosprocket LLC

https://gist.github.com/wboykinm/5533575

Page 27: Sql for Everything: GIS on the Web

SQL For Everything - Bill Morris - Geosprocket LLC

Page 28: Sql for Everything: GIS on the Web

A Query Turns This . . .

SQL For Everything - Bill Morris - Geosprocket LLC

Page 29: Sql for Everything: GIS on the Web

Into This.

SQL For Everything - Bill Morris - Geosprocket LLC

Page 30: Sql for Everything: GIS on the Web

I’m barely scratching the surface of SQL here.

SQL For Everything - Bill Morris - Geosprocket LLC

https://gist.github.com/wboykinm/5533575

Page 31: Sql for Everything: GIS on the Web

Because the web wants to see your data

SQL For Everything - Bill Morris - Geosprocket LLC

Why Care?

Page 32: Sql for Everything: GIS on the Web

SQL For Everything - Bill Morris - Geosprocket LLC

Page 33: Sql for Everything: GIS on the Web

SQL For Everything - Bill Morris - Geosprocket LLC

Page 34: Sql for Everything: GIS on the Web

SQL For Everything - Bill Morris - Geosprocket LLC

Page 35: Sql for Everything: GIS on the Web

SQL For Everything - Bill Morris - Geosprocket LLC

Page 36: Sql for Everything: GIS on the Web

SQL For Everything - Bill Morris - Geosprocket LLC

PostGIS

Page 37: Sql for Everything: GIS on the Web

Thanks! Accepting all questions:

SQL For Everything - Bill Morris - Geosprocket LLC

[email protected]

@vtcraghead