postgis feature frenzy
play

PostGIS Feature Frenzy!!! Wednesday, September 16, 15 frenzy - PowerPoint PPT Presentation

P AUL R AMSEY PRESENTS .... PostGIS Feature Frenzy!!! Wednesday, September 16, 15 frenzy because state of postgis talks only covered leading edge, nothing covering all the good features already there frenzy because our standard 20-25


  1. Geography! Wednesday, September 16, 15 a polygon that covers the pol

  2. Geography! Wednesday, September 16, 15 is wrong if you interpret it on the plane

  3. Geography! Wednesday, September 16, 15 a polygon that crosses the dateline

  4. Geography! Wednesday, September 16, 15 thinks it crosses the whole world if you interpret it on the plane this wasn’t just a problem for postgis

  5. Geography! Wednesday, September 16, 15 even google earth has a hard time with the dateline and polygons also the poles

  6. Geography! Who is geography for? Wednesday, September 16, 15 There two kinds of users who find GEOGRAPHY useful the first is “geonewbies”, users who do not know any GIS or anything about map projections GEOGRAPHY lets them work with lat/lon data without knowing about projections

  7. Geography! Who is GeoNewbies geography for? “I want to find all the address points within one mile! My data is in lat/lon! Google Maps rocks!” Wednesday, September 16, 15 There two kinds of users who find GEOGRAPHY useful the first is “geonewbies”, users who do not know any GIS or anything about map projections GEOGRAPHY lets them work with lat/lon data without knowing about projections

  8. Geography! Who is geography for? Wednesday, September 16, 15 The “geohugies” are really big organizations that have truly global data, that covers the poles and datelines and everything in between there is no map projection that works for them

  9. Geography! Who is GeoHugies geography for? “Yeah, I own a freaking satellite, you got a problem with that?” Wednesday, September 16, 15 The “geohugies” are really big organizations that have truly global data, that covers the poles and datelines and everything in between there is no map projection that works for them

  10. Geography! Geography functions? Wednesday, September 16, 15 the implementation of GEOGRAPHY currently only has support for a few functions but you can use casts to convert to GEOMETRY and access all the geometry function

  11. Geography! Geography functions? • Indexes spherical data Wednesday, September 16, 15 the implementation of GEOGRAPHY currently only has support for a few functions but you can use casts to convert to GEOMETRY and access all the geometry function

  12. Geography! Geography functions? • Indexes spherical data • ST_Intersects() Wednesday, September 16, 15 the implementation of GEOGRAPHY currently only has support for a few functions but you can use casts to convert to GEOMETRY and access all the geometry function

  13. Geography! Geography functions? • Indexes spherical data • ST_Intersects() • ST_Distance() Wednesday, September 16, 15 the implementation of GEOGRAPHY currently only has support for a few functions but you can use casts to convert to GEOMETRY and access all the geometry function

  14. Geography! Geography functions? • Indexes spherical data • ST_Intersects() • ST_Distance() • ST_DWithin() Wednesday, September 16, 15 the implementation of GEOGRAPHY currently only has support for a few functions but you can use casts to convert to GEOMETRY and access all the geometry function

  15. Geography! Geography functions? • Indexes spherical data • ST_Intersects() • ST_Distance() • ST_DWithin() • ST_Area(), ST_Length() Wednesday, September 16, 15 the implementation of GEOGRAPHY currently only has support for a few functions but you can use casts to convert to GEOMETRY and access all the geometry function

  16. Geography! Geography functions? • Indexes spherical data • ST_Intersects() • ST_Distance() • ST_DWithin() • ST_Area(), ST_Length() • Casts to/from GEOMETRY Wednesday, September 16, 15 the implementation of GEOGRAPHY currently only has support for a few functions but you can use casts to convert to GEOMETRY and access all the geometry function

  17. Geography! Wednesday, September 16, 15 There’s a handy new geography function in 2.1, which takes a line, like this one that only has two vertices, on in Paris and one in Los Angeles,

  18. Geography! ST_Segmentize(geog, 300000) Wednesday, September 16, 15 And densifies it in GEOGRAPHIC space, so along the great circle edges between the vertices. This is a 300km densification, and it’s cool to see not only the great circle arc to the north, but the huge distortion in distance in the higher latitudes too. Every vertex here is 300km apart.

  19. shp2pgsql shp2pgsql -D -s 4326 \ -i \ countries.shp \ countries \ | psql -U pramsey \ -d geodatase Wednesday, September 16, 15 before 1.5, this is how you loaded shapefile data

  20. shp2pgsql Wednesday, September 16, 15 PostGIS 1.5 added a GUI loader tool The 2.0 version includes the ability to load multiple files in a batch!

  21. shp2pgsql Wednesday, September 16, 15 PostGIS 1.5 added a GUI loader tool The 2.0 version includes the ability to load multiple files in a batch!

  22. shp2pgsql Wednesday, September 16, 15 PostGIS 1.5 added a GUI loader tool The 2.0 version includes the ability to load multiple files in a batch!

  23. shp2pgsql Wednesday, September 16, 15 PostGIS 1.5 added a GUI loader tool The 2.0 version includes the ability to load multiple files in a batch!

  24. shp2pgsql Wednesday, September 16, 15 PostGIS 1.5 added a GUI loader tool The 2.0 version includes the ability to load multiple files in a batch!

  25. shp2pgsql Wednesday, September 16, 15 PostGIS 1.5 added a GUI loader tool The 2.0 version includes the ability to load multiple files in a batch!

  26. Typmod CREATE TABLE my_spatial_table ( id INTEGER, name VARCHAR(64), geom Geometry(Point,26910) ); Wednesday, September 16, 15 If you’re still on 1.5, it’s time to upgrade! You’ll get “TypMod” support ! lets you declare the type and srid and dimsionality of a geometry right at table CREATE time.

  27. Typmod ALTER TABLE my_spatial_table ALTER COLUMN geom SET DATA TYPE Geometry(Point, 4326) USING ST_Transform(geom, 4326) Wednesday, September 16, 15 With type/srid in the system tables, changing the srid or type of a column becomes a single line of DDL!

  28. Typmod SELECT * FROM geometry_columns WHERE f_table_name = ‘my_spatial_table’ OMG it’s a view now!!!! Wednesday, September 16, 15 With all the type/srid info in the system tables, GEOMETRY_COLUMNS IS A VIEW NOW!

  29. Typmod ------------------+----------------- f_table_catalog | my_database f_table_schema | public f_table_name | my_spatial_table f_geometry_column | geom coord_dimension | 2 srid | 4326 type | POINT Wednesday, September 16, 15

  30. In the 3rd Dimension Wednesday, September 16, 15 There’s lots and lots of new 3D support in recent releases!

  31. 3D Support! 3D Types! • TRIANGLE • TIN • POLYHEDRALSURFACE Wednesday, September 16, 15 We also have 3D types to go with those new functions and indexes.

  32. 3D Support! • ST_3dDistance(geom, geom) • ST_3dLength(geom) • ST_3dClosestPoint(geom, geom) • ST_3dPerimeter(geom) • ST_3dIntersects(geom, geom) • ST_3dDWithin(geom, geom, tolerance) Nik Aven & Wednesday, September 16, 15 The collection of 3D enabled functions has grown a great deal. Distance, length, nearest points, even intersects and within.

  33. 3D Support! 3D Formats! • ST_AsX3D(geom) • ST_AsGML(3, ...) • Also... • ST_AsText(geom) • ST_AsBinary(geom) Wednesday, September 16, 15 And new 3D formats to write those 3D objects out to the wire.

  34. ND-Index! CREATE INDEX my_index ON my_spatial_table USING GIST ( geom gist_nd_geometry_ops ); Wednesday, September 16, 15 Yes, in 2.0 you can create indexes and search in 3D and 4D!

  35. ND-Index! SELECT * FROM my_spatial_table WHERE geom &&& ‘LINESTRING Z (0 0 0, 10 10 10)’ Wednesday, September 16, 15 Yes, in 2.0 you will be able to create indexes and search in 3D and 4D!

  36. 3D Support! Wednesday, September 16, 15 With 2.1, a binding to the CGAL computational geometry library has allowed us to add even more 3D functions than before. This binding will also give us access to more complex CGAL functionality in the future.

  37. 3D Support! • Leveraging the CGAL library • ST_3DIntersection • ST_Tesselate • ST_3DArea • ST_Extrude • ST_ForceLHR • ST_Orientation • ST_Minkowski • ST_StraightSkeleton Wednesday, September 16, 15

  38. Medial Axis N e w 2 t . o 2 ! Wednesday, September 16, 15

  39. Medial Axis N e w 2 t . o 2 ! ST_ApproximateMedialAxis() Wednesday, September 16, 15

  40. Swappable Backend! • Are you freaking kidding me? • set postgis.backend = ‘geos’; set postgis.backend = ‘sfcgal’; • ST_Intersects() ST_3DIntersects() ST_Intersection() ST_Area() ST_Distance() ST_3DDistance() Wednesday, September 16, 15

  41. Raster Types Wednesday, September 16, 15 Raster is a stupid idea, unless you’re doing ANALYSIS

  42. Raster Types Wednesday, September 16, 15 model a raster coverage as a big collection raster chips

  43. Raster Types Wednesday, September 16, 15 So we can do a raster/vector spatial join and ANALYSIS We can join the two tables, finding the slope grid chips that intersect logging areas. And then summarize to find the actual steep slope logging.

  44. Raster Types Wednesday, September 16, 15 ANALYSIS, what if you have areas of interest in vector and data in raster

  45. Raster Types Wednesday, September 16, 15 create a raster mask from the vectors

  46. Raster Types Wednesday, September 16, 15 overlay and summarize! ANALYSIS!

  47. Raster N e w Types 2 Useful Functions t . o 2 ! • ST_SummaryStatsAgg(raster) New in 2.2! • ST_Retile(table) New in 2.2! • ST_CreateOverview(table) New in 2.2! Wednesday, September 16, 15

  48. Topology! Topology Wednesday, September 16, 15 In 2.0 you can create topologies! The classic use case if for data management of things like PARCELS and CADASTRE that have shared boundaries

  49. Topology! Wednesday, September 16, 15 but you can also do fun processing tricks like taking a polygon set with shared boundaries building a topology and

  50. Topology! Wednesday, September 16, 15 simplifying the edges without generating edge gaps

  51. N Topology! e w 2 t . o 2 ! Now in C!!! Wednesday, September 16, 15

  52. Indexed Nearest Indexed KNN Neighbour • KNN = K Nearest Neighbour • Index-based tree search • Restricted to index keys (a.k.a. bounding boxes) • Points: exact answer • Others: box-based answer Wednesday, September 16, 15 PostGIS 2.0 has support for nearest-neighbor indexed searching. For very large tables, with irregular densities, this can be a huge performance win.

  53. Indexed Nearest 2,082,965 GNIS Points Neighbour Wednesday, September 16, 15 So, here’s an example I put together, loading all the USA named geographic points, 2M of them.

  54. Indexed Nearest Neighbour Wednesday, September 16, 15 Find one point, in this case Reedy Creek.

  55. Indexed Nearest Neighbour SELECT id, name, state, kind FROM geonames ORDER BY geom <-> (SELECT geom FROM geonames WHERE id = 4781416) LIMIT 10 Wednesday, September 16, 15 Here’s how we find the 10 nearest names to Reedy Creek. Note the use of the funny arrow- like operator in the ORDER BY clause and the LIMIT. You have to use ORDER BY and you have to LIMIT.

  56. Indexed Nearest Neighbour SELECT id, name, state, kind FROM geonames ORDER BY geom <-> (SELECT geom FROM geonames WHERE id = 4781416) LIMIT 10 Wednesday, September 16, 15 Here’s how we find the 10 nearest names to Reedy Creek. Note the use of the funny arrow- like operator in the ORDER BY clause and the LIMIT. You have to use ORDER BY and you have to LIMIT.

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend