postgis 2postgis 2.x olivier courtin postgresql session #6 - 2014 – paris. postgis spatial...
TRANSCRIPT
![Page 1: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/1.jpg)
PostGIS 2.x
Olivier Courtin
PostgreSQL Session #6 - 2014 – Paris
![Page 2: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/2.jpg)
PostGIS spatial database
2.0.0 04/2012
2.1.0 08/2013
Current version: 2.1.4
Coming 2.2
![Page 3: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/3.jpg)
Management
Advanced spatial analysis
Topology
Raster
Point Cloud
3D
![Page 4: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/4.jpg)
Management
Advanced spatial analysis
Topology
Raster
Point Cloud
3D
![Page 5: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/5.jpg)
CREATE EXTENSION postgis ;
CREATE EXTENSION postgis_topology ;
![Page 6: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/6.jpg)
geometry_columns (and geography_columns)
are now views (rather than table)
![Page 7: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/7.jpg)
![Page 8: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/8.jpg)
UPDATE my_schema.my_table SET geom = ST_CollectionExtract(ST_MakeValid(geom), 3);
![Page 9: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/9.jpg)
Management
Advanced spatial analysis
Topology
Raster
Point Cloud
3D
![Page 10: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/10.jpg)
ST_ConvexHull ST_ConcaveHull
![Page 11: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/11.jpg)
ST_Split
![Page 12: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/12.jpg)
ST_Snap
![Page 13: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/13.jpg)
![Page 14: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/14.jpg)
KNN-GIST: Spatial nearest neighbors
SELECT name, gid FROM geonames ORDER BY geom <-> ST_SetSRID(ST_MakePoint(-90,40),4326) LIMIT 10;
Distance operator: <-> or <#> (center or bbox)
![Page 15: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/15.jpg)
Management
Advanced spatial analysis
Topology
Raster
Point Cloud
3D
![Page 16: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/16.jpg)
Topology
node / edge / face model
ISO SQL/MM functions
Source: Sandro Santilli
![Page 17: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/17.jpg)
Using ST_Simplify without topology
![Page 18: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/18.jpg)
![Page 19: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/19.jpg)
![Page 20: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/20.jpg)
![Page 21: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/21.jpg)
Rec
urs
ive
CT
E 1
2
3
![Page 22: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/22.jpg)
![Page 23: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/23.jpg)
Join result set fromprevious iterationto connected upstreamedges
Stack the gid to the path for this record
Sum up the cost( it's the length here)
If the record gid is alreadyin the path, we have a cycle
Do not take elementswhich make a cycle
![Page 24: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/24.jpg)
Better limit recursive queriesto avoid unfinite loops
Join CTE results to originaltable to get geometries
![Page 25: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/25.jpg)
![Page 26: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/26.jpg)
Management
Advanced spatial analysis
Topology
Raster
Point Cloud
3D
![Page 27: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/27.jpg)
● Raster / vector analysis● New raster datatype (using tiles)● Multiresolution, multiband, tile coverage● Import/export (GDAL)● Raster functions
![Page 28: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/28.jpg)
Source: Pierre Racine
![Page 29: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/29.jpg)
Source: Pierre Racine
![Page 30: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/30.jpg)
Management
Advanced spatial analysis
Topology
Raster
Point Cloud
3D
![Page 31: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/31.jpg)
As PostgreSQL and PostGIS extension
Handle Patches
Arbitrary dimension handling
Data compression
PDAL (as a loader)
![Page 32: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/32.jpg)
Management
Advanced spatial analysis
Topology
Raster
Point Cloud
3D
![Page 33: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/33.jpg)
PostGIS
GEOS SFCGAL
CGAL
![Page 34: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/34.jpg)
![Page 35: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/35.jpg)
ST_3DIntersection
ST_Tesselate
ST_3DArea
ST_Extrude
ST_ForceLHR
ST_Orientation
ST_MinkowskiSum
ST_StraightSkeleton
SFCGAL functions
![Page 36: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/36.jpg)
![Page 37: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/37.jpg)
2D Building Footprint
Straight Skeleton Extrusion & roof computation
![Page 38: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/38.jpg)
ST_Intersects
ST_3DIntersects
ST_Intersection
ST_Area
ST_Distance
ST_3DDistance
Both GEOS & SFCGAL
![Page 39: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/39.jpg)
SET postgis.backend = 'geos' ;
SET postgis.backend = 'sfcgal' ;
![Page 40: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/40.jpg)
SFCGAL perfomances similar to GEOS ones for 2D
(but with SFCGAL we gain arbitrary precision)
![Page 41: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/41.jpg)
SFCGAL perfomances similar to GEOS ones for 2D
(but with SFCGAL we gain arbitrary precision)
But some 3D computation could take time.
![Page 44: PostGIS 2PostGIS 2.x Olivier Courtin PostgreSQL Session #6 - 2014 – Paris. PostGIS spatial database 2.0.0 04/2012 2.1.0 08/2013 Current version: 2.1.4 Coming 2.2. Management Advanced](https://reader034.vdocument.in/reader034/viewer/2022051605/6008100510ccb561b42a61a4/html5/thumbnails/44.jpg)
www.oslandia.com
http://www.postgresql-sessions.org/6/start