spatial database tips & tricks paul ramsey [email protected]
TRANSCRIPT
![Page 2: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/2.jpg)
It’s not dead, it’s just resting…It’s not dead, it’s just resting…
![Page 3: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/3.jpg)
Motivation
• Spatial databases are powerful• Godlike, really• You do not need “GIS software”• Your database is “GIS software”• You do not need “spatial
middleware”• See above
![Page 4: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/4.jpg)
Standard Database
• Has data types– varchar– integer– real– date
![Page 5: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/5.jpg)
Spatial Database
• Has spatial data types– point– linestring– polygon– multipoint– multilinestring– multipolygon
![Page 6: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/6.jpg)
Standard Database
• Has one-dimensional indexes– b-tree– hash
![Page 7: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/7.jpg)
Spatial Database
• Has spatial indexes– r-tree– quad-tree– grid
![Page 8: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/8.jpg)
![Page 9: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/9.jpg)
![Page 10: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/10.jpg)
![Page 11: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/11.jpg)
![Page 12: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/12.jpg)
Find intersecting shapes…
![Page 13: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/13.jpg)
Start with all boxes,
![Page 14: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/14.jpg)
find intersecting boxes,
![Page 15: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/15.jpg)
then find intersecting shapes.
![Page 16: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/16.jpg)
Standard Database
• Has functions• Work against standard types
– lower()– round()– substring()– trim()– dayofweek ()
![Page 17: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/17.jpg)
Spatial Database
• Has spatial functions• Work against spatial types
– ST_Area(geometry)– ST_Distance(geometry,geometry)– ST_Intersects(geometry,geometry)– ST_DWithin(geometry,geometry,radiu
s)– ST_Union(geometry,geometry)
![Page 18: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/18.jpg)
![Page 19: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/19.jpg)
![Page 20: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/20.jpg)
Locator
Spatial
![Page 21: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/21.jpg)
• No buffer operation
• No union operation
• No intersection operation
• No centroid point
• No area or length calculation
L O C A T O R
![Page 22: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/22.jpg)
• Linear referencing system (LRS) support• Spatial analysis and mining functions
and procedures (SDO_SAM package)• Geocoding support (SDO_GCDR
package)• GeoRaster support• Topology data model• Network data model
S P A T I A L
![Page 23: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/23.jpg)
• SFSQL compliant• New release, not as many features• No coordinate reference system
transforms• Windows only• Grid index
![Page 24: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/24.jpg)
SELECT * FROM the_tableWHERE the_geom.STIntersects( geometry::STGeomFromText('POINT(0 0)',0) );
SELECT * FROM the_tableWHERE ST_Intersects( the_geom, ST_GeomFromText('POINT(0 0)',0) );
![Page 25: Spatial Database Tips & Tricks Paul Ramsey pramsey@opengeo.org](https://reader034.vdocument.in/reader034/viewer/2022052510/56649f335503460f94c4f71d/html5/thumbnails/25.jpg)
• PostgreSQL / PostGIS• SFSQL compliant• Open source (GPL)• Proprietary / open source clients• “geographic” coordinates require
care