Upload
kasper-van-lombeek
View
385
Download
0
Embed Size (px)
Citation preview
Why is PostGIS awesome?Reason 1: it is open source
Kasper Van Lombeek - Forespell.com17 / 11 / 2016 - DS Meetup Antwerp
First we need to understand:
Why did SQL need an extension?
Problem 1: data storage
Try to store this rectangle in a db
A db that allows only atomic data points.
P1 P2
P3P4
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
Lets try storing all the neighbourhoods in Belgium?
Solution: SQL 3 custom spatial data types
PostGIS follows the Simple Features for SQL specification from the Open Geospatial Consortium (OGC).
Problem 2: querying the database
How to query our db?
Describe in words how to query the points within the rectangle.
What about a more complex shape?
Would your query still work?
Solution: spatial operators
Provided by GEOS - Geometry Engine, Open Source
Problem 3: querying the database fast
In which area do we have most bicycle thefts?
Need for an index
Solution: spatial index
R-tree implementation of bounding boxes of geometries
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
Demo in IPython notebook