Why is postgis awesome?
-
Upload
kasper-van-lombeek -
Category
Data & Analytics
-
view
383 -
download
0
Transcript of Why is postgis awesome?
![Page 1: Why is postgis awesome?](https://reader035.fdocuments.us/reader035/viewer/2022062523/58ed9b971a28abf84e8b459d/html5/thumbnails/1.jpg)
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?](https://reader035.fdocuments.us/reader035/viewer/2022062523/58ed9b971a28abf84e8b459d/html5/thumbnails/2.jpg)
First we need to understand:
Why did SQL need an extension?
![Page 3: Why is postgis awesome?](https://reader035.fdocuments.us/reader035/viewer/2022062523/58ed9b971a28abf84e8b459d/html5/thumbnails/3.jpg)
Problem 1: data storage
![Page 4: Why is postgis awesome?](https://reader035.fdocuments.us/reader035/viewer/2022062523/58ed9b971a28abf84e8b459d/html5/thumbnails/4.jpg)
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?](https://reader035.fdocuments.us/reader035/viewer/2022062523/58ed9b971a28abf84e8b459d/html5/thumbnails/5.jpg)
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?](https://reader035.fdocuments.us/reader035/viewer/2022062523/58ed9b971a28abf84e8b459d/html5/thumbnails/6.jpg)
Lets try storing all the neighbourhoods in Belgium?
![Page 7: Why is postgis awesome?](https://reader035.fdocuments.us/reader035/viewer/2022062523/58ed9b971a28abf84e8b459d/html5/thumbnails/7.jpg)
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?](https://reader035.fdocuments.us/reader035/viewer/2022062523/58ed9b971a28abf84e8b459d/html5/thumbnails/8.jpg)
Problem 2: querying the database
![Page 9: Why is postgis awesome?](https://reader035.fdocuments.us/reader035/viewer/2022062523/58ed9b971a28abf84e8b459d/html5/thumbnails/9.jpg)
How to query our db?
Describe in words how to query the points within the rectangle.
![Page 10: Why is postgis awesome?](https://reader035.fdocuments.us/reader035/viewer/2022062523/58ed9b971a28abf84e8b459d/html5/thumbnails/10.jpg)
What about a more complex shape?
Would your query still work?
![Page 11: Why is postgis awesome?](https://reader035.fdocuments.us/reader035/viewer/2022062523/58ed9b971a28abf84e8b459d/html5/thumbnails/11.jpg)
Solution: spatial operators
Provided by GEOS - Geometry Engine, Open Source
![Page 12: Why is postgis awesome?](https://reader035.fdocuments.us/reader035/viewer/2022062523/58ed9b971a28abf84e8b459d/html5/thumbnails/12.jpg)
Problem 3: querying the database fast
![Page 13: Why is postgis awesome?](https://reader035.fdocuments.us/reader035/viewer/2022062523/58ed9b971a28abf84e8b459d/html5/thumbnails/13.jpg)
In which area do we have most bicycle thefts?
![Page 14: Why is postgis awesome?](https://reader035.fdocuments.us/reader035/viewer/2022062523/58ed9b971a28abf84e8b459d/html5/thumbnails/14.jpg)
Need for an index
![Page 15: Why is postgis awesome?](https://reader035.fdocuments.us/reader035/viewer/2022062523/58ed9b971a28abf84e8b459d/html5/thumbnails/15.jpg)
Solution: spatial index
R-tree implementation of bounding boxes of geometries
![Page 16: Why is postgis awesome?](https://reader035.fdocuments.us/reader035/viewer/2022062523/58ed9b971a28abf84e8b459d/html5/thumbnails/16.jpg)
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?](https://reader035.fdocuments.us/reader035/viewer/2022062523/58ed9b971a28abf84e8b459d/html5/thumbnails/17.jpg)
Demo in IPython notebook