PostGIS 3.5.0dev手册

DEV (Thu 21 Sep 2023 07:23:39 AM UTC rev. 4395b1f )

PostGIS 开发团队

Abstract

PostGIS 是一种扩展功能,适用于 PostgreSQL 对象关系数据库系统,它允许将 GIS(地理信息系统)对象存储在数据库中。PostGIS 包含对基于 GiST 的 R-Tree 空间索引的支持,以及用于分析和处理 GIS 对象的功能。

本手册的版本是 3.5.0dev

本作品已获得创作共用署名-相同方式共享 3.0 许可。。请随意使用这份材料,任何您喜欢的方式,但我们要求您将荣誉归于 PostGIS 项目,尽可能提供返回https://postgis.net的链接。


Table of Contents
1. 介绍
1.1. 项目指导委员会
1.2. 当前的核心贡献者
1.3. 过去的核心贡献者
1.4. 其它贡献者
2. PostGIS 安装
2.1. 简短版本
2.2. 从源代码编译和安装
2.2.1. 获取源代码
2.2.2. 安装要求
2.2.3. 构建配置
2.2.4. 构建
2.2.5. 构建和部署PostGIS扩展
2.2.6. 测试
2.2.7. 安装
2.3. 安装和使用地址标准化工具
2.4. 安装、升级 Tiger Geocoder 并加载数据
2.4.1. 在 PostGIS 数据库中启用Tiger Geocoder
2.4.2. 在 PostGIS 数据库中启用 Tiger 地理编码器:使用扩展名
2.4.3. 加载tiger所需的工具
2.4.4. 升级 Tiger 地理编码器和数据
2.5. 常见问题
3. PostGIS 管理
3.1. Performance Tuning
3.1.1. Startup
3.1.2. Runtime
3.2. 配置栅格支持
3.3. 创建空间数据库
3.3.1. 使用「扩展(EXTENSION)」来在数据库上启用空间能力
3.3.2. 不通过扩展(EXTENSION)的方式启用空间数据库(不建议)
3.4. 升级空间数据库
3.4.1. 软升级
3.4.2. 硬升级
4. 数据管理
4.1. 空间数据模型
4.1.1. OGC几何图形
4.1.2. SQL/MM第3部分-曲线
4.1.3. WKT和WKB
4.2. 几何数据类型
4.2.1. PostGIS EWKB 和 EWKT
4.3. 地理数据类型
4.3.1. 创建地理表
4.3.2. 使用地理表
4.3.3. 何时使用地理数据类型
4.3.4. 地理高级常见问题解答
4.4. 几何有效性验证
4.4.1. 简单几何
4.4.2. 有效的几何形状
4.4.3. 有效性管理
4.5. 空间参考系统
4.5.1. SPATIAL_REF_SYS表
4.5.2. 用户自定义空间参考系统
4.6. 空间表
4.6.1. 创建空间表
4.6.2. GEOMETRY_COLUMNS 视图
4.6.3. 手动注册几何列
4.7. 加载空间数据
4.7.1. 使用SOL加载数据
4.7.2. 使用Shapefile加载器
4.8. 提取空间数据
4.8.1. 使用SQL提取数据
4.8.2. 使用Shapefile文件转储程序
4.9. 空间索引
4.9.1. GiST 索引
4.9.2. BRIN 索引
4.9.3. SP-GiST 索引
4.9.4. 调优索引的使用
5. 空间查询
5.1. 空间关系的确定
5.1.1. 维度扩展9相交模型(Dimensionally Extended 9-Intersection Model)
5.1.2. 命名空间关系
5.1.3. 一般空间关系
5.2. 使用空间索引
5.3. 空间SQL示例
6. 性能优化技巧
6.1. 大几何形状的小表
6.1.1. 问题描述
6.1.2. 解决办法
6.2. 几何索引聚类
6.3. 避免维度变换
7. PostGIS 参考手册
7.1. PostGIS Geometry/Geography/Box 数据类型
box2d — 表示二维边界框的类型。
box3d — 表示二维边界框的类型。
geometry — 表示具有平面坐标系的空间要素的类型。
geometry_dump — 用于描述复杂几何形状部分的复合类型。
geography — 使用大地(椭球)坐标系表示空间特征的类型。
7.2. 表管理功能
AddGeometryColumn — 将geometry(几何)列添加到现有表。
DropGeometryColumn — 从空间表中移除geometry(几何)列。
DropGeometryTable — 删除表及其在geometry_columns中的所有引用。
Find_SRID — 返回geometry(几何)列中定义的 SRID。
Populate_Geometry_Columns — 确保几何列由类型修饰符定义或具有适当的空间约束。
UpdateGeometrySRID — 更新几何列中所有要素的 SRID 以及表元数据。
7.3. 几何构造函数
ST_Collect — 从一组几何图形创建 GeometryCollection 或 Multi* 几何图形。
ST_LineFromMultiPoint — 从多点几何创建线串。
ST_MakeEnvelope — 根据最小和最大坐标创建矩形多边形。
ST_MakeLine — 从Point, MultiPoint,或LineString geometries创建LineString。
ST_MakePoint — 创建 2D、3DZ 或 4D 点。
ST_MakePointM — 根据 X、Y 和 M 值创建一个点。
ST_MakePolygon — 从壳和可选的孔列表创建多边形。
ST_Point — 创建具有 X、Y 和 SRID 值的点。
ST_PointZ — 创建具有 X、Y、Z 和 SRID 值的点。
ST_PointM — 创建具有 X、Y、M 和 SRID 值的点。
ST_PointZM — 创建具有 X、Y、Z、M 和 SRID 值的点。
ST_Polygon — 从具有指定 SRID 的线串创建多边形。
ST_TileEnvelope — 使用 XYZ 切片系统在 Web Mercator (SRID:3857) 中创建矩形多边形。
ST_HexagonGrid — 返回一组完全覆盖几何参数边界的六边形和单元格索引。
ST_Hexagon — 使用提供的边尺寸和六边形网格空间内的单元坐标返回单个六边形。
ST_SquareGrid — 返回一组完全覆盖几何参数边界的网格正方形和单元格索引。
ST_Square — 使用提供的边缘大小和正方形网格空间内的单元格坐标返回单个正方形。
ST_Letters — 返回以几何图形绘制的文本,默认起始位置为原点,默认高度为 100。
7.4. 几何访问器
GeometryType — 以文本形式返回几何的类型。
ST_Boundary — 返回几何图形的边界。
ST_BoundingDiagonal — 返回几何边界框的对角线。
ST_CoordDim — 返回几何体的坐标维度。
ST_Dimension — 返回几何图形的拓扑维数。
ST_Dump — 返回几何组件的一组 geometry_dump行。
ST_DumpPoints — 返回几何图形中坐标的一组 geometry_dump 行。
ST_DumpSegments — 为几何图形中的各个线段返回一组geometry_dump行。
ST_DumpRings — 返回多边形外环和内环的一组geometry_dump行。
ST_EndPoint — 返回 LineString 或 CircularLineString 的最后一个点。
ST_Envelope — 返回表示几何图形边界框的几何图形。
ST_ExteriorRing — 返回表示多边形外环的LineString。
ST_GeometryN — 返回几何集合的一个元素。
ST_GeometryType — 以文本形式返回几何图形的 SQL-MM 类型。
ST_HasArc — 测试几何图形是否包含圆弧
ST_InteriorRingN — 返回多边形的第 N 个内环(孔)。
ST_IsClosed — 测试 LineStrings 的起点和终点是否重合。 对于多面体表面测试是否闭合(实心)。
ST_IsCollection — 测试几何类型是否为几何集合。
ST_IsEmpty — 检测几何图形是否为空。
ST_IsPolygonCCW — 检测多边形是否具有逆时针方向的外环和顺时针方向的内环。
ST_IsPolygonCW — 检测多边形是否具有顺时针外环和逆时针内环。
ST_IsRing — 检测线串是闭合的还是简单的。
ST_IsSimple — 检测几何体的自完整性或自接触点。
ST_M — 返回点的 M 值。
ST_MemSize — 返回几何图形占用的内存空间总量。
ST_NDims — 返回几何体的坐标维度。
ST_NPoints — 返回几何图形中的点数(顶点)。
ST_NRings — 返回多边形几何中的环数。
ST_NumGeometries — 返回几何集合中的元素数量。
ST_NumInteriorRings — 返回多边形的内环(孔)数。
ST_NumInteriorRing — 返回多边形的内环(孔)数。ST_NumInteriorRings的别名
ST_NumPatches — 返回多面体曲面上的面数。 对于非多面体几何形状将返回 null。
ST_NumPoints — 返回 LineString 或 CircularString 中的点数。
ST_PatchN — 返回多边形曲面(PolyhedralSurface)的第 N 个几何体(面)。
ST_PointN — 返回几何图形中第一个线串或圆形线串中的第 N 个点。
ST_Points — 返回包含几何坐标的 MultiPoint。
ST_StartPoint — 返回 LineString 的第一个点.
ST_Summary — 返回几何内容的文本摘要。
ST_X — 返回点的 X 坐标。
ST_Y — 返回点的Y坐标。
ST_Z — 返回点的Z坐标。
ST_Zmflag — 返回指示几何体的 ZM 坐标维度的代码。
7.5. 几何编辑器
ST_AddPoint — 将点添加到线串(LineString)。
ST_CollectionExtract — 给定一个几何集合,返回仅包含指定类型元素的多几何图形。
ST_CollectionHomogenize — 返回几何集合的最简单表示。
ST_CurveToLine — 将包含曲线的几何图形转换为线性几何图形。
ST_Scroll — 更改闭合线串的起点。
ST_FlipCoordinates — 返回 X 轴和 Y 轴转换的几何图形版本。
ST_Force2D — 强制几何图形进入“二维模式”。
ST_Force3D — 强制几何图形进入 XYZ 模式。 这是 ST_Force3DZ 的别名。
ST_Force3DZ — 强制几何图形进入 XYZ 模式。
ST_Force3DM — 强制几何图形进入 XYM 模式。
ST_Force4D — 强制几何图形进入XYZM模式。
ST_ForcePolygonCCW — 将所有外环逆时针定向,将所有内环顺时针定向。
ST_ForceCollection — 将几何图形转换为几何集合(GEOMETRYCOLLECTION)。
ST_ForcePolygonCW — 顺时针方向调整所有外环,逆时针方向调整所有内环。
ST_ForceSFS — 强制几何图形仅使用 SFS 1.1 几何类型。
ST_ForceRHR — 强制多边形顶点的方向遵循右手定则。
ST_ForceCurve — 如果适用,将一个几何图形上升到其曲线类型。
ST_LineToCurve — 将线性几何图形转换为曲线几何图形。
ST_Multi — 将几何图形返回为 MULTI* 几何图形。
ST_LineExtend — 返回一条线,其中最后一段和第一段延伸了指定的距离。
ST_Normalize — 返回规范形式的几何图形。
ST_Project — 返回从起点按距离和方位角(方位角)投影的点。
ST_QuantizeCoordinates — 将坐标的最低有效位设置为零
ST_RemovePoint — 从线串中删除一个点。
ST_RemoveRepeatedPoints — 返回删除了重复点的几何图形。
ST_Reverse — 返回顶点顺序相反的几何体。
ST_Segmentize — 返回修改后的几何图形/地理,其线段不长于给定距离。
ST_SetPoint — 用给定点替换线串的点。
ST_ShiftLongitude — 在 -180-180 和 0-360 之间移动几何图形的经度坐标。
ST_WrapX — 将几何体环绕在 X 值周围。
ST_SnapToGrid — 将输入几何体的所有点捕捉到规则网格。
ST_Snap — 将输入几何体的线段和顶点捕捉到参考几何体的顶点。
ST_SwapOrdinates — 返回更改后的几何图形,其中交换了给定的坐标值。
7.6. 几何有效性验证
ST_IsValid — 测试几何图形在 2D 中是否有效。
ST_IsValidDetail — 返回 valid_detail 行,说明几何图形是否有效或无效,说明原因和位置。
ST_IsValidReason — 返回说明几何图形是否有效或无效原因的文本。
ST_MakeValid — 尝试在不丢失顶点的情况下使无效几何体有效。
7.7. 空间参考系统功能
ST_InverseTransformPipeline — 返回一个新的几何体,其坐标值使用定义的坐标变换管道的逆变换变换到不同的空间参考系。
ST_SetSRID — 在几何体上设置 SRID。
ST_SRID — 返回几何图形的空间参考标识符。
ST_Transform — 返回坐标转换为不同空间参考系的新几何图形。
ST_TransformPipeline — 返回一个新的几何图形,其坐标使用定义的坐标转换管道转换为不同的空间参考系统。
postgis_srs_codes — 返回与给定权限关联的 SRS 代码列表。
postgis_srs — 返回所请求的权限和 srid 的元数据记录。
postgis_srs_all — 返回底层 Proj 数据库中每个空间参考系统的元数据记录。
postgis_srs_search — 返回具有完全包含边界参数的使用区域的投影坐标系的元数据记录。
7.8. 几何输入
7.8.1. Well-Known Text (WKT)
7.8.2. 已知的二进制文件 (WKB)
7.8.3. 其它格式
7.9. 几何输出
7.9.1. Well-Known Text (WKT)
7.9.2. 已知的二进制文件 (WKB)
7.9.3. 其它格式
7.10. 运算符
7.10.1. 边界框运算符
7.10.2. 距离运算符
7.11. 空间关系
7.11.1. 拓扑关系
7.11.2. 距离关系
7.12. 测量函数
ST_Area — 返回多边形几何体的面积。
ST_Azimuth — 返回两点之间直线的基于北方的方位角。
ST_Angle — 返回由 3 或 4 个点或 2 条线定义的两个向量之间的角度。
ST_ClosestPoint — 返回 g1 上最接近 g2 的 2D 点。 这是从一个几何体到另一个几何体的最短直线的第一个点。
ST_3DClosestPoint — 返回 g1 上最接近 g2 的 3D 点。 这是 3D 最短线的第一个点。
ST_Distance — 返回两个几何或地理值之间的距离。
ST_3DDistance — 返回两个几何图形之间的 3D 笛卡尔最小距离(基于空间参考)(以投影单位表示)。
ST_DistanceSphere — 使用球形地球模型返回两个经度/纬度几何形状之间的最小距离(以米为单位)。
ST_DistanceSpheroid — 使用球体模型返回两个经度/纬度几何形状之间的最小距离。
ST_FrechetDistance — 返回两个几何图形之间的 Fréchet 距离。
ST_HausdorffDistance — 返回两个几何图形之间的Hausdorff 距离。
ST_Length — 返回线性几何体的二维长度。
ST_Length2D — 返回线性几何体的二维长度。 ST_Length 的别名
ST_3DLength — 返回线性几何体的 3D 长度。
ST_LengthSpheroid — 返回椭球体上经度/纬度几何体的 2D 或 3D 长度/周长。
ST_LongestLine — 返回两个几何图形之间的二维最长线。
ST_3DLongestLine — 返回两个几何体之间的 3D 最长直线
ST_MaxDistance — 返回两个几何图形之间的二维最大距离(以投影单位表示)。
ST_3DMaxDistance — 返回两个几何图形之间的 3D 笛卡尔最大距离(基于空间参考)(以投影单位表示)。
ST_MinimumClearance — 返回几何体的最小间隙,这是几何体稳健性的度量。
ST_MinimumClearanceLine — 返回跨越几何体最小间隙的两点线串。
ST_Perimeter — 返回多边形几何或地理的边界长度。
ST_Perimeter2D — 返回多边形几何体的 2D 周长。 ST_Perimeter 的别名。
ST_3DPerimeter — 返回多边形几何体的 3D 周长。
ST_ShortestLine — 返回两个几何图形之间的 2D 最短线
ST_3DShortestLine — 返回两个几何图形之间的 3D 最短线
7.13. 叠加函数
ST_ClipByBox2D — 计算几何图形落在矩形内的部分。
ST_Difference — 计算表示几何 A 中不与几何 B 相交的部分的几何。
ST_Intersection — 计算表示几何 A 和 B 的共享部分的几何。
ST_MemUnion — 聚合函数,以内存高效但速度较慢的方式联合几何图形
ST_Node — 节点是线的集合。
ST_Split — 返回通过将一个几何体分割为另一个几何体而创建的几何体集合。
ST_Subdivide — 计算几何体的直线细分。
ST_SymDifference — 计算表示几何图形 A 和 B 不相交部分的几何图形。
ST_UnaryUnion — 计算单个几何体的组件的并集。
ST_Union — 计算表示输入几何图形的点集合并的几何图形。
7.14. 几何处理
ST_Buffer — 计算覆盖距几何体给定距离内所有点的几何体。
ST_BuildArea — 创建由几何体的线条形成的多边形几何体。
ST_Centroid — 返回几何体的几何中心。
ST_ChaikinSmoothing — 使用 Chaikin 算法返回几何图形的平滑版本
ST_ConcaveHull — 计算包含所有输入几何顶点的可能凹几何
ST_ConvexHull — 计算几何体的凸包。
ST_DelaunayTriangles — 返回几何体顶点的 Delaunay 三角剖分。
ST_FilterByM — 根据 M 值删除顶点
ST_GeneratePoints — 生成一个包含在多边形(Polygon)或多重多边形(MultiPolygon)内的随机点的多点对象。
ST_GeometricMedian — 返回多点的几何中位数。
ST_LineMerge — 返回通过将 MultiLineString 缝合在一起形成的线。
ST_MaximumInscribedCircle — 计算几何体中包含的最大圆。
ST_LargestEmptyCircle — 计算不与几何图形重叠的最大圆。
ST_MinimumBoundingCircle — 返回包含几何图形的最小圆形多边形。
ST_MinimumBoundingRadius — 返回包含几何图形的最小圆的中心点和半径。
ST_OrientedEnvelope — 返回包含几何图形的最小面积矩形。
ST_OffsetCurve — 返回距输入线给定距离和方向的偏移线。
ST_PointOnSurface — 计算保证位于多边形或几何体上的点。
ST_Polygonize — 计算由一组几何图形的线条形成的多边形集合。
ST_ReducePrecision — 返回有效的几何图形,其点舍入到网格公差。
ST_SharedPaths — 返回一个集合,其中包含两个输入线串/多线串共享的路径。
ST_Simplify — 使用 Douglas-Peucker 算法返回几何的简化版本。
ST_SimplifyPreserveTopology — 使用 Douglas-Peucker 算法返回几何的简化且有效的版本。
ST_SimplifyPolygonHull — 计算多边形几何的简化的保留拓扑的外部或内部外壳。
ST_SimplifyVW — 使用 Visvalingam-Whyatt 算法返回几何的简化版本
ST_SetEffectiveArea — 使用 Visvalingam-Whyatt 算法设置每个顶点的有效区域。
ST_TriangulatePolygon — 计算多边形的约束 Delaunay 三角剖分
ST_VoronoiLines — 返回几何体顶点的 Voronoi 图的边界。
ST_VoronoiPolygons — 返回几何体顶点的 Voronoi 图的单元格。
7.15. 覆盖范围
ST_CoverageInvalidEdges — 用于查找多边形无法形成有效覆盖范围的位置的窗口函数。
ST_CoverageSimplify — 简化多边形覆盖范围边缘的窗口函数。
ST_CoverageUnion — 通过删除共享边来计算形成覆盖范围的一组多边形的并集。
7.16. 仿射变换
ST_Affine — 对几何体应用 3D 仿射变换。
ST_Rotate — 绕原点旋转几何体。
ST_RotateX — 绕 X 轴旋转几何体。
ST_RotateY — 绕 Y 轴旋转几何体。
ST_RotateZ — 绕 Z 轴旋转几何体。
ST_Scale — 按给定因子缩放几何图形。
ST_Translate — 按给定的偏移量平移几何图形。
ST_TransScale — 按给定的偏移量和系数平移和缩放几何图形。
7.17. 聚类函数
ST_ClusterDBSCAN — 使用 DBSCAN 算法返回每个输入几何图形的簇 id 的窗口函数。
ST_ClusterIntersecting — 将输入几何图形聚类成连接集的聚合函数。
ST_ClusterIntersectingWin — 窗口函数,返回每个输入几何图形的簇 ID,将输入几何图形聚类到连接的集合中。
ST_ClusterKMeans — 使用 K 均值算法返回每个输入几何图形的簇 id 的窗口函数。
ST_ClusterWithin — 按间隔距离对几何图形进行聚合的聚合函数。
ST_ClusterWithinWin — 窗口函数,返回每个输入几何图形的簇 ID,使用分离距离进行聚类。
7.18. 边界框函数
Box2D — 返回表示几何图形的 2D 范围的 BOX2D。
Box3D — 返回表示几何体 3D 范围的 BOX3D。
ST_EstimatedExtent — 返回空间表的估计范围。
ST_Expand — 返回从另一个边界框或几何图形扩展的边界框。
ST_Extent — 返回几何图形边界框的聚合函数。
ST_3DExtent — 返回几何图形的 3D 边界框的聚合函数。
ST_MakeBox2D — 创建由两个 2D 点几何图形定义的 BOX2D。
ST_3DMakeBox — 创建由两个 3D 点几何图形定义的 BOX3D。
ST_XMax — 返回 2D 或 3D 边界框或几何体的 X 最大值。
ST_XMin — 返回 2D 或 3D 边界框或几何体的 X 最小值。
ST_YMax — 返回 2D 或 3D 边界框或几何体的 Y 最大值。
ST_YMin — 返回 2D 或 3D 边界框或几何体的 Y 最小值。
ST_ZMax — 返回 2D 或 3D 边界框或几何体的 Z 最大值。
ST_ZMin — 返回 2D 或 3D 边界框或几何体的 Z 最小值。
7.19. 线性参考
ST_LineInterpolatePoint — 返回沿线在百分比指示位置的插值点。
ST_3DLineInterpolatePoint — 返回沿 3D 线的小数指示位置插值的点。
ST_LineInterpolatePoints — 返回沿直线以分数间隔插值的点。
ST_LineLocatePoint — 返回线上最接近点的分数位置。
ST_LineSubstring — 返回两个小数位置之间的直线部分。
ST_LocateAlong — 返回几何上与测量值匹配的点。
ST_LocateBetween — 返回与测量范围匹配的几何图形部分。
ST_LocateBetweenElevations — 返回位于高程 (Z) 范围内的几何图形部分。
ST_InterpolatePoint — 返回最接近点的几何图形的插值测量值。
ST_AddMeasure — 沿线性几何形状插值测量值。
7.20. 轨迹函数
ST_IsValidTrajectory — 测试几何图形是否为有效轨迹。
ST_ClosestPointOfApproach — 返回两条轨迹最接近点处的测量值。
ST_DistanceCPA — 返回两条轨迹的最近接近点之间的距离。
ST_CPAWithin — 测试两条轨迹的最近接近点是否在指定距离内。
7.21. SFCGAL 函数
postgis_sfcgal_version — 返回正在使用的 SFCGAL 版本
postgis_sfcgal_full_version — 返回正在使用的 SFCGAL 的完整版本,包括 CGAL 和 Boost 版本
ST_3DArea — 计算 3D 表面几何形状的面积。 对于固体将返回 0。
ST_3DConvexHull — 计算几何体的 3D 凸包。
ST_3DIntersection — 执行 3D 相交
ST_3DDifference — 执行 3D 差异
ST_3DUnion — 执行 3D 联合。
ST_AlphaShape — 计算包围几何体的 Alpha 形状
ST_ApproximateMedialAxis — 计算几何区域的近似中轴。
ST_ConstrainedDelaunayTriangles — 返回围绕给定输入几何体的约束 Delaunay 三角剖分。
ST_Extrude — 将曲面挤出到相关体积
ST_ForceLHR — 强制 LHR 方向
ST_IsPlanar — 检查表面是否平坦
ST_IsSolid — 测试几何体是否为实体。 不执行有效性检查。
ST_MakeSolid — 将几何体铸造成实体。 不执行任何检查。 要获得有效的实体,输入几何图形必须是闭合多面体曲面或闭合 TIN。
ST_MinkowskiSum — 执行 Minkowski sum
ST_OptimalAlphaShape — 使用“最佳”alpha 值计算包围几何体的 Alpha 形状。
ST_Orientation — 确定表面方向
ST_StraightSkeleton — 从几何体计算直骨架
ST_Tesselate — 对多边形或多面体表面执行曲面细分,并以 TIN 或 TINS 集合的形式返回
ST_Volume — 计算 3D 实体的体积。 如果应用于表面(甚至闭合)几何图形将返回 0。
7.22. 长事务支持
AddAuth — 添加要在当前事务中使用的授权令牌。
CheckAuth — 在表上创建触发器,以根据授权令牌阻止/允许更新和删除行。
DisableLongTransactions — 禁用长事务支持。
EnableLongTransactions — 启用长事务支持。
LockRow — 为表中的行设置锁定/授权。
UnlockRows — 删除授权令牌持有的所有锁。
7.23. 版本函数
PostGIS_Extensions_Upgrade — 将 PostGIS 扩展(例如 postgis_raster、postgis_topology、postgis_sfcgal)打包并升级到给定版本或最新版本。
PostGIS_Full_Version — 报告完整的 PostGIS 版本和构建配置信息。
PostGIS_GEOS_Version — 返回 GEOS 库的版本号。
PostGIS_GEOS_Compiled_Version — 返回构建 PostGIS 所依据的 GEOS 库的版本号。
PostGIS_Liblwgeom_Version — 返回 liblwgeom 库的版本号。 这应该与 PostGIS 的版本匹配。
PostGIS_LibXML_Version — 返回 libxml2 库的版本号。
PostGIS_Lib_Build_Date — 返回 PostGIS 库的构建日期。
PostGIS_Lib_Version — 返回 PostGIS 库的版本号。
PostGIS_PROJ_Version — 返回 PROJ4 库的版本号。
PostGIS_Wagyu_Version — 返回内部 Wagyu 库的版本号。
PostGIS_Scripts_Build_Date — 返回 PostGIS 脚本的构建日期。
PostGIS_Scripts_Installed — 返回此数据库中安装的 PostGIS 脚本的版本。
PostGIS_Scripts_Released — 返回随安装的 PostGIS 库一起发布的 postgis.sql 脚本的版本号。
PostGIS_Version — 返回 PostGIS 版本号和编译时选项。
7.24. 大一统自定义变量 (GUCs)
postgis.backend — 为 GEOS 和 SFCGAL 重叠的功能提供服务的后端。 选项:geos 或 sfcgal。 默认为geos。
postgis.gdal_datapath — 用于分配 GDAL 的 GDAL_DATA 选项值的配置选项。 如果未设置,则使用环境设置的 GDAL_DATA 变量。
postgis.gdal_enabled_drivers — 用于设置 PostGIS 环境中启用的 GDAL 驱动程序的配置选项。 影响 GDAL 配置变量 GDAL_SKIP。
postgis.enable_outdb_rasters — 一个布尔配置选项,用于启用对数据库外栅格波段的访问。
postgis.gdal_config_options — 用于设置处理外部数据库栅格时使用的选项的字符串配置。
7.25. 故障排除函数
PostGIS_AddBBox — 向几何体添加边界框。
PostGIS_DropBBox — 从几何体中删除边界框缓存。
PostGIS_HasBBox — 如果该几何体的 bbox 已缓存,则返回 TRUE,否则返回 FALSE。
8. 拓扑结构
8.1. 拓扑类型
getfaceedges_returntype — 由序号和边号组成的复合类型。
TopoGeometry — 表示拓扑定义的几何图形的复合类型。
validatetopology_returntype — 复合类型,由错误消息以及表示错误位置的 id1 和 id2 组成。 这是 ValidateTopology 的返回类型。
8.2. 拓扑域
TopoElement — 一个由 2 个整数组成的数组,用于表示简单或分层拓扑几何的一个组件。
TopoElementArray — TopoElement 对象的数组。
8.3. 拓扑和拓扑几何管理
AddTopoGeometryColumn — 将拓扑几何列添加到现有表中,将此新列注册为topology.layer 中的图层并返回新的layer_id。
RenameTopoGeometryColumn — 重命名拓扑几何列
DropTopology — 谨慎使用:删除拓扑模式并从topology.topology 表中删除其引用,并从geometry_columns 表中删除对该模式中表的引用。
RenameTopology — 重命名拓扑
DropTopoGeometryColumn — 从架构 schema_name 中名为 table_name 的表中删除拓扑几何列,并从 topology.layer 表中取消注册这些列。
Populate_Topology_Layer — 通过从拓扑表读取元数据,将缺失的条目添加到topology.layer表中。
TopologySummary — 获取拓扑名称并提供拓扑中对象类型的汇总总数。
ValidateTopology — 返回一组 validatetopology_returntype 对象,详细说明拓扑问题。
ValidateTopologyRelation — 返回有关无效拓扑关系记录的信息
FindTopology — 通过不同的方式返回拓扑记录。
FindLayer — 通过不同的方式返回topology.layer记录。
8.4. 拓扑统计管理
8.5. 拓扑构造器
CreateTopology — 创建一个新的拓扑架构并将其注册到topology.topology 表中。
CopyTopology — 将拓扑(节点、边、面、层和拓扑几何)的副本复制到新模式中
ST_InitTopoGeo — 创建一个新的拓扑架构并将其注册到topology.topology 表中。
ST_CreateTopoGeo — 将几何图形集合添加到给定的空拓扑并返回详细说明成功的消息。
TopoGeo_AddPoint — 使用容差并可能分割现有边向现有拓扑添加点。
TopoGeo_AddLineString — 使用公差并可能分割现有边/面,将线串添加到现有拓扑。 返回边标识符。
TopoGeo_AddPolygon — 使用公差并可能分割现有边/面将多边形添加到现有拓扑。 返回面标识符。
8.6. 拓扑编辑器
ST_AddIsoNode — 将一个孤立的节点添加到拓扑结构中的一个面,并返回新节点的节点ID。如果"face"为空(null),仍然会创建节点。
ST_AddIsoEdge — 将由几何 alinestring 定义的孤立边添加到连接两个现有孤立节点anodeanothernode的拓扑,并返回新边的边id。
ST_AddEdgeNewFaces — 添加新边,如果这样做会分割一个面,请删除原始面并用两个新面替换它。
ST_AddEdgeModFace — 添加新边,如果这样做会分割面,则修改原始面并添加新面。
ST_RemEdgeNewFace — 删除一条边,如果删除的边将两个面分开,则删除原始面并用新面替换它们。
ST_RemEdgeModFace — 删除一条边,如果该边将两个面分开,则删除一个面并修改另一个面以覆盖两个面的空间。
ST_ChangeEdgeGeom — 改变边的形状而不影响拓扑结构。
ST_ModEdgeSplit — 通过沿现有边创建新节点、修改原始边并添加新边来分割边。
ST_ModEdgeHeal — 通过删除连接两条边的节点、修改第一条边并删除第二条边来修复两条边。 返回已删除节点的 id。
ST_NewEdgeHeal — 通过删除连接两条边的节点、删除两条边并用方向与提供的第一条边相同的边替换它们来修复两条边。
ST_MoveIsoNode — 在拓扑结构中将一个孤立节点从一个点移动到另一个点。如果新的apoint几何对象已存在作为一个节点,则会抛出错误。返回移动的描述。
ST_NewEdgesSplit — 通过沿现有边创建新节点、删除原始边并用两条新边替换它来分割边。 返回创建的连接新边的新节点的 id。
ST_RemoveIsoNode — 删除孤立节点并返回操作描述。 如果节点不是孤立的(是边的开始或结束),则会引发异常。
ST_RemoveIsoEdge — 删除孤立的边并返回操作的描述。 如果边缘未被隔离,则会引发异常。
8.7. 拓扑访问器
GetEdgeByPoint — 查找与给定点相交的边的边 ID。
GetFaceByPoint — 查找与给定点相交的面。
GetFaceContainingPoint — 查找包含点的面。
GetNodeByPoint — 查找某个点位置处节点的节点 ID。
GetTopologyID — 返回topology.topology表中给定拓扑名称的拓扑的id。
GetTopologySRID — 返回拓扑表中给定拓扑名称的拓扑的 SRID。
GetTopologyName — 返回给定拓扑 ID 的拓扑(架构)名称。
ST_GetFaceEdges — 返回一组有序的边,这些边界绑定了aface
ST_GetFaceGeometry — 返回给定拓扑中具有指定面 ID 的多边形。
GetRingEdges — 返回按顺序排列的边标识符集合,这些标识符是通过沿给定边的一侧行走时遇到的。
GetNodeEdges — 返回与给定节点相关的一组有序边。
8.8. 拓扑处理
Polygonize — 查找并注册由拓扑边定义的所有面。
AddNode — 将点节点添加到指定拓扑模式的节点表中,并返回新节点的nodeid。 如果点已经作为节点存在,则返回现有的nodeid。
AddEdge — 使用指定的线串几何将线串边添加到边表,并将关联的起点和终点添加到指定拓扑方案的点节点表,并返回新(或现有)边的edgeid。
AddFace — 将面基元注册到拓扑并获取其标识符。
ST_Simplify — 使用 Douglas-Peucker 算法返回给定 TopoGeometry 的“简化”几何版本。
RemoveUnusedPrimitives — 删除定义现有 TopoGeometry 对象不需要的拓扑基元。
8.9. 拓扑几何构造函数
CreateTopoGeom — 从拓扑元素数组创建一个新的拓扑几何对象 - tg_type: 1:[多]点, 2:[多]线, 3:[多]多边形, 4:集合
toTopoGeom — 将简单几何图形转换为拓扑几何图形。
TopoElementArray_Agg — 返回一组 element_id、类型数组 (topoelements) 的 topoelementarray
TopoElement — 将拓扑几何转换为拓扑元素。
8.10. 拓扑几何编辑器
clearTopoGeom — 清除拓扑几何的内容。
TopoGeom_addElement — 将元素添加到 TopoGeometry 的定义中。
TopoGeom_remElement — 从 TopoGeometry 的定义中删除元素。
TopoGeom_addTopoGeom — 将一个 TopoGeometry 的元素添加到另一个 TopoGeometry 的定义中。
toTopoGeom — 将几何形状添加到现有拓扑几何图形中。
8.11. 拓扑几何访问器
GetTopoGeomElementArray — 返回一个topoelementarray(包含拓扑元素的数组),其中包含给定TopoGeometry的拓扑元素和类型(原始元素)。
GetTopoGeomElements — 返回一组 topoelement 对象,其中包含给定 TopoGeometry(原始元素)的拓扑 element_id、element_type。
ST_SRID — 返回拓扑几何的空间参考标识符。
8.12. 拓扑几何输出
AsGML — 返回拓扑几何的 GML 表示形式。
AsTopoJSON — 返回拓扑几何的 TopoJSON 表示形式。
8.13. 拓扑空间关系
Equals — 如果两个拓扑几何由相同的拓扑基元组成,则返回 true。
Intersects — 如果两个拓扑几何中的任何一对图元相交,则返回 true。
8.14. 导入和导出拓扑
8.14.1. 使用拓扑导出器
8.14.2. 使用拓扑导入器
9. 栅格数据管理、查询和应用程序
9.1. 加载和创建栅格
9.1.1. 使用 raster2pgsql 加载栅格
9.1.2. 使用 PostGIS 栅格函数创建栅格
9.1.3. 使用“out db”云栅格
9.2. 光栅目录
9.2.1. 栅格列目录
9.2.2. 光栅概述
9.3. 使用 PostGIS Raster 构建自定义应用程序
9.3.1. PHP 示例使用 ST_AsPNG 与其他栅格函数进行输出
9.3.2. ASP.NET C# 示例使用 ST_AsPNG 与其他栅格函数进行输出
9.3.3. 将栅格查询输出为图像文件的 Java 控制台应用程序
9.3.4. 使用 PLPython 通过 SQL 转储图像
9.3.5. 使用 PSQL 输出栅格
10. 栅格参考
10.1. 栅格支持数据类型
geomval — 具有两个字段的空间数据类型 - geom(保存几何对象)和 val(保存栅格带中的双精度像素值)。
addbandarg — 用作 ST_AddBand 函数的输入的复合类型,定义新波段的属性和初始值。
rastbandarg — 需要表达栅格和该栅格的波段索引时使用的复合类型。
raster — 栅格空间数据类型。
reclassarg — 用作定义重新分类行为的 ST_Reclass 函数的输入的复合类型。
summarystats — ST_SummaryStats 和 ST_SummaryStatsAgg 函数返回的复合类型。
unionarg — 用作 ST_Union 函数的输入的复合类型,定义要处理的波段和 UNION 操作的行为。
10.2. 栅格管理
AddRasterConstraints — 将栅格约束添加到已加载的栅格表中,用于特定列,该列约束了空间参考、比例、块大小、对齐、波段、波段类型以及一个标志,用于表示栅格列是否被规则地分块。表必须加载数据才能推断出约束。如果约束设置成功,则返回 true,否则会发出通知。
DropRasterConstraints — 删除引用栅格表列的 PostGIS 栅格约束。 如果您需要重新加载数据或更新栅格列数据,则非常有用。
AddOverviewConstraints — 将栅格列标记为另一栅格列的概述。
DropOverviewConstraints — 取消栅格列作为另一栅格列概览的标记。
PostGIS_GDAL_Version — 报告 PostGIS 使用的 GDAL 库的版本。
PostGIS_Raster_Lib_Build_Date — 报告完整的栅格库构建日期。
PostGIS_Raster_Lib_Version — 报告完整的栅格版本和构建配置信息。
ST_GDALDrivers — 通过 GDAL 返回 PostGIS 支持的栅格格式列表。 ST_AsGDALRaster 仅可使用 can_write=True 的格式
ST_Contour — 使用 GDAL 轮廓算法从提供的栅格波段生成一组矢量轮廓。
ST_InterpolateRaster — 基于输入的 3 维点集插值网格表面,使用 X 和 Y 值在网格上定位点,并使用点的 Z 值作为表面高程。
UpdateRasterSRID — 更改用户指定的列和表中所有栅格的 SRID。
ST_CreateOverview — 创建给定栅格覆盖范围的降低分辨率版本。
10.3. 栅格构造器
ST_AddBand — 返回一个栅格,其中在给定索引位置添加了给定类型的新波段和给定初始值。 如果未指定索引,则将带添加到末尾。
ST_AsRaster — 将 PostGIS 几何图形转换为 PostGIS 栅格。
ST_Band — 返回现有栅格的一个或多个波段作为新栅格。 对于从现有栅格构建新栅格非常有用。
ST_MakeEmptyCoverage — 用空栅格图块网格覆盖地理参考区域。
ST_MakeEmptyRaster — 返回一个空白栅格(不包含波段),其具有给定的尺寸(宽度和高度)、左上角 X 和 Y 坐标、像素大小和旋转参数(scalex、scaley、skewx 和 skewy),以及参考系统(SRID)。如果传递了一个栅格,则返回一个具有相同大小、对齐方式和 SRID 的新栅格。如果省略了 SRID,则空间参考将设置为未知(0)。
ST_Tile — 返回根据输出栅格的所需维度分割输入栅格而产生的一组栅格。
ST_Retile — 从任意平铺的栅格覆盖范围返回一组配置的平铺。
ST_FromGDALRaster — 从受支持的 GDAL 栅格文件返回栅格。
10.4. 栅格访问器
ST_GeoReference — 返回 GDAL 或 ESRI 格式的地理配准元数据,如世界文件中常见的格式。 默认为 GDAL。
ST_Height — 返回栅格的高度(以像素为单位)。
ST_IsEmpty — 如果栅格为空(宽度 = 0 且高度 = 0),则返回 true。 否则,返回 false。
ST_MemSize — 返回栅格占用的空间量(以字节为单位)。
ST_MetaData — 返回有关栅格对象的基本元数据,例如像素大小、旋转(倾斜)、左上、左下等。
ST_NumBands — 返回栅格对象中的波段数。
ST_PixelHeight — 返回空间参考系统的几何单位的像素高度。
ST_PixelWidth — 返回空间参考系统的几何单位的像素宽度。
ST_ScaleX — 返回像素宽度的 X 分量(以坐标参考系为单位)。
ST_ScaleY — 返回像素高度的 Y 分量(以坐标参考系为单位)。
ST_RasterToWorldCoord — 在给定列和行的情况下,以几何 X 和 Y(经度和纬度)形式返回栅格的左上角。 列和行从 1 开始。
ST_RasterToWorldCoordX — 返回栅格、列和行左上角的几何 X 坐标。 列和行的编号从 1 开始。
ST_RasterToWorldCoordY — 返回栅格、列和行的左上角的几何 Y 坐标。 列和行的编号从 1 开始。
ST_Rotation — 返回栅格的旋转弧度。
ST_SkewX — 返回地理参考 X 倾斜(或旋转参数)。
ST_SkewY — 返回地理参考 Y 倾斜(或旋转参数)。
ST_SRID — 返回在spatial_ref_sys表中定义的栅格的空间参考标识符。
ST_Summary — 返回栅格内容的文本摘要。
ST_UpperLeftX — 返回投影空间参考中栅格的左上角 X 坐标。
ST_UpperLeftY — 返回投影空间参考中栅格的左上角 Y 坐标。
ST_Width — 返回栅格的宽度(以像素为单位)。
ST_WorldToRasterCoord — 给定几何 X 和 Y(经度和纬度)或以栅格的空间参考坐标系表示的点几何,将左上角作为列和行返回。
ST_WorldToRasterCoordX — 返回栅格中点几何 (pt) 的列或以栅格世界空间参考系表示的 X 和 Y 世界坐标 (xw, yw)。
ST_WorldToRasterCoordY — 返回点几何图形 (pt) 的栅格中的行或以栅格的世界空间参考系表示的 X 和 Y 世界坐标 (xw, yw)。
10.5. 栅格波段访问器
ST_BandMetaData — 返回特定栅格波段的基本元数据。 如果未指定,则假定波段编号为 1。
ST_BandNoDataValue — 返回表示无数据的给定波段中的值。如果没有指定波段编号,默认为波段1。
ST_BandIsNoData — 如果波段仅填充无数据值,则返回 true。
ST_BandPath — 返回存储在文件系统中的波段的系统文件路径。 如果未指定 bandnum,则假定为 1。
ST_BandFileSize — 返回文件系统中存储的波段的文件大小。 如果未指定 bandnum,则假定为 1。
ST_BandFileTimestamp — 返回文件系统中存储的波段的文件时间戳。 如果未指定 bandnum,则假定为 1。
ST_BandPixelType — 返回给定波段的像素类型。 如果未指定 bandnum,则假定为 1。
ST_MinPossibleValue — 返回此像素类型可以存储的最小值。
ST_HasNoBand — 如果不存在具有给定波段编号的波段,则返回 true。 如果未指定波段号,则假定波段号为 1。
10.6. 栅格像素访问器和设置器
ST_PixelAsPolygon — 返回限定特定行和列的像素的多边形几何形状。
ST_PixelAsPolygons — 返回包围栅格带的每个像素的多边形几何图形以及每个像素的值、X 和 Y 栅格坐标。
ST_PixelAsPoint — 返回像素左上角的点几何形状。
ST_PixelAsPoints — 返回栅格波段的每个像素的点几何图形以及每个像素的值、X 和 Y 栅格坐标。 点几何的坐标是像素的左上角。
ST_PixelAsCentroid — 返回像素表示的区域的质心(点几何)。
ST_PixelAsCentroids — 返回栅格波段的每个像素的质心(点几何)以及每个像素的值、X 和 Y 栅格坐标。 点几何是像素表示的区域的质心。
ST_Value — 返回指定列 x、行 y 像素或特定几何点处给定波段的值。波段编号从 1 开始,如果未指定,则默认为 1。如果将参数 exclude_nodata_value 设置为 false,则所有像素都被认为与 nodata 像素相交并返回其值。如果未传递参数 exclude_nodata_value,则从栅格的元数据中读取该值。
ST_NearestValue — 返回由 columnx 和 rowy 指定的给定带像素的最接近的非 NODATA 值或以与栅格相同的空间参考坐标系表示的几何点。
ST_SetZ — 返回与输入几何图形具有相同 X/Y 坐标的几何图形,并使用请求的重采样算法将栅格中的值复制到 Z 维度。
ST_SetM — 返回与输入几何图形具有相同 X/Y 坐标的几何图形,并使用请求的重采样算法将栅格中的值复制到 M 维度。
ST_Neighborhood — 返回给定波段像素周围非 NODATA 值的二维双精度数组,该给定波段像素由 columnX 和 rowY 或以与栅格相同的空间参考坐标系表示的几何点指定。
ST_SetValue — 返回修改后的栅格,其结果是将给定波段中的值设置为指定列x、行y像素或与特定几何图形相交的像素。波段编号从1开始,如果未指定波段,则默认为1。
ST_SetValues — 返回通过设置给定波段的值而产生的修改后的栅格。
ST_DumpValues — 获取指定 band(波段) 的值作为二维数组。
ST_PixelOfValue — 获取值等于搜索值的像素的列x、行y坐标。
10.7. 栅格编辑器
ST_SetGeoReference — Set Georeference 6 georeference parameters in a single call. Numbers should be separated by white space. Accepts inputs in GDAL or ESRI format. Default is GDAL.
ST_SetRotation — Set the rotation of the raster in radian.
ST_SetScale — Sets the X and Y size of pixels in units of coordinate reference system. Number units/pixel width/height.
ST_SetSkew — Sets the georeference X and Y skew (or rotation parameter). If only one is passed in, sets X and Y to the same value.
ST_SetSRID — Sets the SRID of a raster to a particular integer srid defined in the spatial_ref_sys table.
ST_SetUpperLeft — Sets the value of the upper left corner of the pixel of the raster to projected X and Y coordinates.
ST_Resample — Resample a raster using a specified resampling algorithm, new dimensions, an arbitrary grid corner and a set of raster georeferencing attributes defined or borrowed from another raster.
ST_Rescale — Resample a raster by adjusting only its scale (or pixel size). New pixel values are computed using the NearestNeighbor (english or american spelling), Bilinear, Cubic, CubicSpline, Lanczos, Max or Min resampling algorithm. Default is NearestNeighbor.
ST_Reskew — Resample a raster by adjusting only its skew (or rotation parameters). New pixel values are computed using the NearestNeighbor (english or american spelling), Bilinear, Cubic, CubicSpline or Lanczos resampling algorithm. Default is NearestNeighbor.
ST_SnapToGrid — Resample a raster by snapping it to a grid. New pixel values are computed using the NearestNeighbor (english or american spelling), Bilinear, Cubic, CubicSpline or Lanczos resampling algorithm. Default is NearestNeighbor.
ST_Resize — Resize a raster to a new width/height
ST_Transform — Reprojects a raster in a known spatial reference system to another known spatial reference system using specified resampling algorithm. Options are NearestNeighbor, Bilinear, Cubic, CubicSpline, Lanczos defaulting to NearestNeighbor.
10.8. Raster Band Editors
ST_SetBandNoDataValue — Sets the value for the given band that represents no data. Band 1 is assumed if no band is specified. To mark a band as having no nodata value, set the nodata value = NULL.
ST_SetBandIsNoData — Sets the isnodata flag of the band to TRUE.
ST_SetBandPath — Update the external path and band number of an out-db band
ST_SetBandIndex — Update the external band number of an out-db band
10.9. Raster Band Statistics and Analytics
ST_Count — Returns the number of pixels in a given band of a raster or raster coverage. If no band is specified defaults to band 1. If exclude_nodata_value is set to true, will only count pixels that are not equal to the nodata value.
ST_CountAgg — Aggregate. Returns the number of pixels in a given band of a set of rasters. If no band is specified defaults to band 1. If exclude_nodata_value is set to true, will only count pixels that are not equal to the NODATA value.
ST_Histogram — Returns a set of record summarizing a raster or raster coverage data distribution separate bin ranges. Number of bins are autocomputed if not specified.
ST_Quantile — Compute quantiles for a raster or raster table coverage in the context of the sample or population. Thus, a value could be examined to be at the raster's 25%, 50%, 75% percentile.
ST_SummaryStats — Returns summarystats consisting of count, sum, mean, stddev, min, max for a given raster band of a raster or raster coverage. Band 1 is assumed is no band is specified.
ST_SummaryStatsAgg — Aggregate. Returns summarystats consisting of count, sum, mean, stddev, min, max for a given raster band of a set of raster. Band 1 is assumed is no band is specified.
ST_ValueCount — Returns a set of records containing a pixel band value and count of the number of pixels in a given band of a raster (or a raster coverage) that have a given set of values. If no band is specified defaults to band 1. By default nodata value pixels are not counted. and all other values in the pixel are output and pixel band values are rounded to the nearest integer.
10.10. Raster Inputs
ST_RastFromWKB — Return a raster value from a Well-Known Binary (WKB) raster.
ST_RastFromHexWKB — Return a raster value from a Hex representation of Well-Known Binary (WKB) raster.
10.11. Raster Outputs
ST_AsBinary/ST_AsWKB — Return the Well-Known Binary (WKB) representation of the raster.
ST_AsHexWKB — Return the Well-Known Binary (WKB) in Hex representation of the raster.
ST_AsGDALRaster — Return the raster tile in the designated GDAL Raster format. Raster formats are one of those supported by your compiled library. Use ST_GDALDrivers() to get a list of formats supported by your library.
ST_AsJPEG — Return the raster tile selected bands as a single Joint Photographic Exports Group (JPEG) image (byte array). If no band is specified and 1 or more than 3 bands, then only the first band is used. If only 3 bands then all 3 bands are used and mapped to RGB.
ST_AsPNG — Return the raster tile selected bands as a single portable network graphics (PNG) image (byte array). If 1, 3, or 4 bands in raster and no bands are specified, then all bands are used. If more 2 or more than 4 bands and no bands specified, then only band 1 is used. Bands are mapped to RGB or RGBA space.
ST_AsTIFF — Return the raster selected bands as a single TIFF image (byte array). If no band is specified or any of specified bands does not exist in the raster, then will try to use all bands.
10.12. Raster Processing: Map Algebra
ST_Clip — Returns the raster clipped by the input geometry. If band number not is specified, all bands are processed. If crop is not specified or TRUE, the output raster is cropped.
ST_ColorMap — Creates a new raster of up to four 8BUI bands (grayscale, RGB, RGBA) from the source raster and a specified band. Band 1 is assumed if not specified.
ST_Grayscale — Creates a new one-8BUI band raster from the source raster and specified bands representing Red, Green and Blue
ST_Intersection — Returns a raster or a set of geometry-pixelvalue pairs representing the shared portion of two rasters or the geometrical intersection of a vectorization of the raster and a geometry.
ST_MapAlgebra (callback function version) — Callback function version - Returns a one-band raster given one or more input rasters, band indexes and one user-specified callback function.
ST_MapAlgebra (expression version) — Expression version - Returns a one-band raster given one or two input rasters, band indexes and one or more user-specified SQL expressions.
ST_MapAlgebraExpr — 1 raster band version: Creates a new one band raster formed by applying a valid PostgreSQL algebraic operation on the input raster band and of pixeltype provided. Band 1 is assumed if no band is specified.
ST_MapAlgebraExpr — 2 raster band version: Creates a new one band raster formed by applying a valid PostgreSQL algebraic operation on the two input raster bands and of pixeltype provided. band 1 of each raster is assumed if no band numbers are specified. The resulting raster will be aligned (scale, skew and pixel corners) on the grid defined by the first raster and have its extent defined by the "extenttype" parameter. Values for "extenttype" can be: INTERSECTION, UNION, FIRST, SECOND.
ST_MapAlgebraFct — 1 band version - Creates a new one band raster formed by applying a valid PostgreSQL function on the input raster band and of pixeltype prodived. Band 1 is assumed if no band is specified.
ST_MapAlgebraFct — 2 band version - Creates a new one band raster formed by applying a valid PostgreSQL function on the 2 input raster bands and of pixeltype prodived. Band 1 is assumed if no band is specified. Extent type defaults to INTERSECTION if not specified.
ST_MapAlgebraFctNgb — 1-band version: Map Algebra Nearest Neighbor using user-defined PostgreSQL function. Return a raster which values are the result of a PLPGSQL user function involving a neighborhood of values from the input raster band.
ST_Reclass — Creates a new raster composed of band types reclassified from original. The nband is the band to be changed. If nband is not specified assumed to be 1. All other bands are returned unchanged. Use case: convert a 16BUI band to a 8BUI and so forth for simpler rendering as viewable formats.
ST_Union — Returns the union of a set of raster tiles into a single raster composed of 1 or more bands.
10.13. Built-in Map Algebra Callback Functions
ST_Distinct4ma — Raster processing function that calculates the number of unique pixel values in a neighborhood.
ST_InvDistWeight4ma — Raster processing function that interpolates a pixel's value from the pixel's neighborhood.
ST_Max4ma — Raster processing function that calculates the maximum pixel value in a neighborhood.
ST_Mean4ma — Raster processing function that calculates the mean pixel value in a neighborhood.
ST_Min4ma — Raster processing function that calculates the minimum pixel value in a neighborhood.
ST_MinDist4ma — Raster processing function that returns the minimum distance (in number of pixels) between the pixel of interest and a neighboring pixel with value.
ST_Range4ma — Raster processing function that calculates the range of pixel values in a neighborhood.
ST_StdDev4ma — Raster processing function that calculates the standard deviation of pixel values in a neighborhood.
ST_Sum4ma — Raster processing function that calculates the sum of all pixel values in a neighborhood.
10.14. Raster Processing: DEM (Elevation)
ST_Aspect — Returns the aspect (in degrees by default) of an elevation raster band. Useful for analyzing terrain.
ST_HillShade — Returns the hypothetical illumination of an elevation raster band using provided azimuth, altitude, brightness and scale inputs.
ST_Roughness — Returns a raster with the calculated "roughness" of a DEM.
ST_Slope — Returns the slope (in degrees by default) of an elevation raster band. Useful for analyzing terrain.
ST_TPI — Returns a raster with the calculated Topographic Position Index.
ST_TRI — Returns a raster with the calculated Terrain Ruggedness Index.
10.15. Raster Processing: Raster to Geometry
Box3D — Returns the box 3d representation of the enclosing box of the raster.
ST_ConvexHull — Return the convex hull geometry of the raster including pixel values equal to BandNoDataValue. For regular shaped and non-skewed rasters, this gives the same result as ST_Envelope so only useful for irregularly shaped or skewed rasters.
ST_DumpAsPolygons — Returns a set of geomval (geom,val) rows, from a given raster band. If no band number is specified, band num defaults to 1.
ST_Envelope — Returns the polygon representation of the extent of the raster.
ST_MinConvexHull — Return the convex hull geometry of the raster excluding NODATA pixels.
ST_Polygon — Returns a multipolygon geometry formed by the union of pixels that have a pixel value that is not no data value. If no band number is specified, band num defaults to 1.
10.16. Raster Operators
&& — Returns TRUE if A's bounding box intersects B's bounding box.
&< — Returns TRUE if A's bounding box is to the left of B's.
&> — Returns TRUE if A's bounding box is to the right of B's.
= — Returns TRUE if A's bounding box is the same as B's. Uses double precision bounding box.
@ — Returns TRUE if A's bounding box is contained by B's. Uses double precision bounding box.
~= — 如果 A 的边界框与 B 的边界框相同,则返回 TRUE
~ — Returns TRUE if A's bounding box is contains B's. Uses double precision bounding box.
10.17. Raster and Raster Band Spatial Relationships
ST_Contains — Return true if no points of raster rastB lie in the exterior of raster rastA and at least one point of the interior of rastB lies in the interior of rastA.
ST_ContainsProperly — Return true if rastB intersects the interior of rastA but not the boundary or exterior of rastA.
ST_Covers — Return true if no points of raster rastB lie outside raster rastA.
ST_CoveredBy — Return true if no points of raster rastA lie outside raster rastB.
ST_Disjoint — Return true if raster rastA does not spatially intersect rastB.
ST_Intersects — Return true if raster rastA spatially intersects raster rastB.
ST_Overlaps — Return true if raster rastA and rastB intersect but one does not completely contain the other.
ST_Touches — Return true if raster rastA and rastB have at least one point in common but their interiors do not intersect.
ST_SameAlignment — Returns true if rasters have same skew, scale, spatial ref, and offset (pixels can be put on same grid without cutting into pixels) and false if they don't with notice detailing issue.
ST_NotSameAlignmentReason — Returns text stating if rasters are aligned and if not aligned, a reason why.
ST_Within — Return true if no points of raster rastA lie in the exterior of raster rastB and at least one point of the interior of rastA lies in the interior of rastB.
ST_DWithin — Return true if rasters rastA and rastB are within the specified distance of each other.
ST_DFullyWithin — Return true if rasters rastA and rastB are fully within the specified distance of each other.
10.18. Raster Tips
10.18.1. Out-DB Rasters
11. PostGIS 补充
11.1. 地址标准化工具
11.1.1. How the Parser Works
11.1.2. Address Standardizer Types
11.1.3. Address Standardizer Tables
11.1.4. Address Standardizer Functions
11.2. Tiger Geocoder
Drop_Indexes_Generate_Script — Generates a script that drops all non-primary key and non-unique indexes on tiger schema and user specified schema. Defaults schema to tiger_data if no schema is specified.
Drop_Nation_Tables_Generate_Script — Generates a script that drops all tables in the specified schema that start with county_all, state_all or state code followed by county or state.
Drop_State_Tables_Generate_Script — Generates a script that drops all tables in the specified schema that are prefixed with the state abbreviation. Defaults schema to tiger_data if no schema is specified.
Geocode — Takes in an address as a string (or other normalized address) and outputs a set of possible locations which include a point geometry in NAD 83 long lat, a normalized address for each, and the rating. The lower the rating the more likely the match. Results are sorted by lowest rating first. Can optionally pass in maximum results, defaults to 10, and restrict_region (defaults to NULL)
Geocode_Intersection — Takes in 2 streets that intersect and a state, city, zip, and outputs a set of possible locations on the first cross street that is at the intersection, also includes a geomout as the point location in NAD 83 long lat, a normalized_address (addy) for each location, and the rating. The lower the rating the more likely the match. Results are sorted by lowest rating first. Can optionally pass in maximum results, defaults to 10. Uses Tiger data (edges, faces, addr), PostgreSQL fuzzy string matching (soundex, levenshtein).
Get_Geocode_Setting — Returns value of specific setting stored in tiger.geocode_settings table.
Get_Tract — Returns census tract or field from tract table of where the geometry is located. Default to returning short name of tract.
Install_Missing_Indexes — Finds all tables with key columns used in geocoder joins and filter conditions that are missing used indexes on those columns and will add them.
Loader_Generate_Census_Script — Generates a shell script for the specified platform for the specified states that will download Tiger census state tract, bg, and tabblocks data tables, stage and load into tiger_data schema. Each state script is returned as a separate record.
Loader_Generate_Script — Generates a shell script for the specified platform for the specified states that will download Tiger data, stage and load into tiger_data schema. Each state script is returned as a separate record. Latest version supports Tiger 2010 structural changes and also loads census tract, block groups, and blocks tables.
Loader_Generate_Nation_Script — Generates a shell script for the specified platform that loads in the county and state lookup tables.
Missing_Indexes_Generate_Script — Finds all tables with key columns used in geocoder joins that are missing indexes on those columns and will output the SQL DDL to define the index for those tables.
Normalize_Address — Given a textual street address, returns a composite norm_addy type that has road suffix, prefix and type standardized, street, streetname etc. broken into separate fields. This function will work with just the lookup data packaged with the tiger_geocoder (no need for tiger census data).
Pagc_Normalize_Address — Given a textual street address, returns a composite norm_addy type that has road suffix, prefix and type standardized, street, streetname etc. broken into separate fields. This function will work with just the lookup data packaged with the tiger_geocoder (no need for tiger census data). Requires address_standardizer extension.
Pprint_Addy — Given a norm_addy composite type object, returns a pretty print representation of it. Usually used in conjunction with normalize_address.
Reverse_Geocode — Takes a geometry point in a known spatial ref sys and returns a record containing an array of theoretically possible addresses and an array of cross streets. If include_strnum_range = true, includes the street range in the cross streets.
Topology_Load_Tiger — Loads a defined region of tiger data into a PostGIS Topology and transforming the tiger data to spatial reference of the topology and snapping to the precision tolerance of the topology.
Set_Geocode_Setting — Sets a setting that affects behavior of geocoder functions.
12. PostGIS Special Functions Index
12.1. PostGIS Aggregate Functions
12.2. PostGIS Window Functions
12.3. PostGIS SQL-MM Compliant Functions
12.4. PostGIS Geography Support Functions
12.5. PostGIS Raster Support Functions
12.6. PostGIS Geometry / Geography / Raster Dump Functions
12.7. PostGIS Box Functions
12.8. PostGIS Functions that support 3D
12.9. PostGIS Curved Geometry Support Functions
12.10. PostGIS Polyhedral Surface Support Functions
12.11. PostGIS Function Support Matrix
12.12. New, Enhanced or changed PostGIS Functions
12.12.1. PostGIS Functions new or enhanced in 3.4
12.12.2. PostGIS Functions new or enhanced in 3.3
12.12.3. PostGIS Functions new or enhanced in 3.2
12.12.4. PostGIS Functions new or enhanced in 3.1
12.12.5. PostGIS Functions new or enhanced in 3.0
12.12.6. PostGIS Functions new or enhanced in 2.5
12.12.7. PostGIS Functions new or enhanced in 2.4
12.12.8. PostGIS Functions new or enhanced in 2.3
12.12.9. PostGIS Functions new or enhanced in 2.2
12.12.10. PostGIS Functions new or enhanced in 2.1
12.12.11. PostGIS Functions new or enhanced in 2.0
12.12.12. PostGIS Functions new or enhanced in 1.5
12.12.13. PostGIS Functions new or enhanced in 1.4
12.12.14. PostGIS Functions new or enhanced in 1.3
13. Reporting Problems
13.1. Reporting Software Bugs
13.2. Reporting Documentation Issues
A. Appendix
A.1. PostGIS 3.4.0