当 Postgres 已经有地理类型时需要 Postgis

Need for Postgis when Postgres already has geo type

我正在考虑安装 PostGIS extension for Postgres. However, upon looking at the types in Postgres itself, it seems to support the basic Geometric types,包括:

8.8.1. Points
8.8.2. Lines
8.8.3. Line Segments
8.8.4. Boxes
8.8.5. Paths
8.8.6. Polygons
8.8.7. Circles

那么,使用 PostGIS 的用例是什么?在处理空间数据时,Postgres 本身不会给我什么? (忽略 UI 注意事项)。

地球表面不是无限大的二维平面。将其近似为一个是否合理取决于您在做什么。

这完全取决于您的用例。如果您打算应用简单的空间操作,例如包含或距离,则原生几何数据类型可以解决问题。但无论如何,这里有一些东西可以代表 PostGIS:

  • PostGIS 是一个不断发展的庞大开源项目。
  • 1.3k多真的kickass functions that abstract most of the cumbersome math involved in spatio-temporal queries. Think only about operations like Spatial Reference System (SRS) transformations, projections or simply handling polyhedral surfaces and you will soon realize the complexity involved with geo spatial data. Believe me, it is not trivial. Even the simple feature of rendering geo spatial data in different formats like WKT, KML or GeoJSON可以节省你很多时间!
  • 它使您能够轻松访问大多数现代 GI 软件的数据。想要将您的数据绘制到地图中吗? ;)
  • 它可以作为OGC Standard web services, such as Web Feature Service (WFS) or Web Map Service (WMS). Take a look at GeoServer的数据源。
  • 它在 GIS 社区中得到了很好的采用,这意味着您可以在线找到大量内容和支持。
  • 它同时支持矢量和栅格数据类型。
  • 它提供(多维)空间索引。众所周知,地理空间数据集非常庞大,因此必须有适当的索引机制才能在合适的查询时间内执行空间操作。
  • 它提供网络拓扑支持。
  • 它是其他非常方便的扩展的构建块,例如pgRouting and ogrfdw.

优点不胜枚举。

这里有一些可以使用 PostGIS 轻松解决的现实生活用例: