why is postgis awesome?

17
Why is PostGIS awesome? Reason 1: it is open source Kasper Van Lombeek - Forespell.com 17 / 11 / 2016 - DS Meetup Antwerp

Upload: kasper-van-lombeek

Post on 12-Apr-2017

385 views

Category:

Data & Analytics


0 download

TRANSCRIPT

Page 1: Why is postgis awesome?

Why is PostGIS awesome?Reason 1: it is open source

Kasper Van Lombeek - Forespell.com17 / 11 / 2016 - DS Meetup Antwerp

Page 2: Why is postgis awesome?

First we need to understand:

Why did SQL need an extension?

Page 3: Why is postgis awesome?

Problem 1: data storage

Page 4: Why is postgis awesome?

Try to store this rectangle in a db

A db that allows only atomic data points.

P1 P2

P3P4

Page 5: Why is postgis awesome?

Lets tryPid X Y

P1 0 0

P2 0 1

P3 1 1

P4 1 0

Table 1: points

Eid Pid

E1 P1

E1 P2

E2 P2

E2…

P3…

Table 3: Starts_or_ends

Eid

Length

E1 1

E2 1

E3 1

E4 1

Table 2: EdgesP1 P2

P3P4

E1

E2

E3

E4

Rid

Eid

R1 E1

R1 E2

R1 E3

R1…

E4…

Table 4: Boundary

Rid Rname

R1 UnitSquare

Table 5: Rectangle

Page 6: Why is postgis awesome?

Lets try storing all the neighbourhoods in Belgium?

Page 7: Why is postgis awesome?

Solution: SQL 3 custom spatial data types

PostGIS follows the Simple Features for SQL specification from the Open Geospatial Consortium (OGC).

Page 8: Why is postgis awesome?

Problem 2: querying the database

Page 9: Why is postgis awesome?

How to query our db?

Describe in words how to query the points within the rectangle.

Page 10: Why is postgis awesome?

What about a more complex shape?

Would your query still work?

Page 11: Why is postgis awesome?

Solution: spatial operators

Provided by GEOS - Geometry Engine, Open Source

Page 12: Why is postgis awesome?

Problem 3: querying the database fast

Page 13: Why is postgis awesome?

In which area do we have most bicycle thefts?

Page 14: Why is postgis awesome?

Need for an index

Page 15: Why is postgis awesome?

Solution: spatial index

R-tree implementation of bounding boxes of geometries

Page 16: Why is postgis awesome?

These three solutions are integrated in PostGIS

- Geometry types for Points, LineStrings, Polygons, MultiPoints, MultiLineStrings, MultipPolygons and GeometryCollections.- Spatial predicates for determining the interactions of geometries using the 3x3 DE-9IM (provided by the GEOS software library).- Spatial operators for determining geospatial measurements like area, distance, length and perimeter.- Spatial operators for determining geospatial set operations, like union, difference, symmetric difference and buffers (provided by GEOS).- R-tree-over-GiST (Generalized Search Tree) spatial indexes for high speed spatial querying.- Index selectivity support, to provide high performance query plans for mixed spatial/non-spatial queries.- For raster data, PostGIS WKT Raster (now integrated into PostGIS 2.0+ and renamed PostGIS Raster)- The PostGIS implementation is based on "light-weight" geometries and indexes optimized to reduce disk and memory footprint. Using light-weight geometries helps servers increase the amount of data migrated up from physical disk storage into RAM, improving query performance substantially.- PostGIS is registered as "implements the specified standard" for "Simple Features for SQL" by the OGC.[2] PostGIS has not been certified as compliant by the OGC. For the OGC's definition of compliant, see What does "Compliant" mean?.

Source: wikipedia

Page 17: Why is postgis awesome?

Demo in IPython notebook