PostGIS 3.5.0dev Manual

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

The PostGIS Development Group

Abstract

PostGIS is an extension to the PostgreSQL object-relational database system which allows GIS (Geographic Information Systems) objects to be stored in the database. PostGIS includes support for GiST-based R-Tree spatial indexes, and functions for analysis and processing of GIS objects.

This is the manual for version 3.5.0dev

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License. Feel free to use this material any way you like, but we ask that you attribute credit to the PostGIS Project and wherever possible, a link back to https://postgis.net.


Table of Contents
1. Introduction
1.1. Project Steering Committee
1.2. Core Contributors Present
1.3. Core Contributors Past
1.4. Other Contributors
2. PostGIS Installation
2.1. Short Version
2.2. Compiling and Install from Source
2.2.1. Getting the Source
2.2.2. Install Requirements
2.2.3. Build configuration
2.2.4. Building
2.2.5. Building PostGIS Extensions and Deploying them
2.2.6. Testing
2.2.7. Installation
2.3. Installing and Using the address standardizer
2.4. Installing, Upgrading Tiger Geocoder, and loading data
2.4.1. Tiger Geocoder Enabling your PostGIS database
2.4.2. Using Address Standardizer Extension with Tiger geocoder
2.4.3. Required tools for tiger data loading
2.4.4. Upgrading your Tiger Geocoder Install and Data
2.5. Common Problems during installation
3. PostGIS Administration
3.1. Performance Tuning
3.1.1. Startup
3.1.2. Runtime
3.2. Configuring raster support
3.3. Creating spatial databases
3.3.1. Spatially enable database using EXTENSION
3.3.2. Spatially enable database without using EXTENSION (discouraged)
3.4. Upgrading spatial databases
3.4.1. Soft upgrade
3.4.2. Hard upgrade
4. Data Management
4.1. Spatial Data Model
4.1.1. OGC Geometry
4.1.2. SQL/MM Part 3 - Curves
4.1.3. WKT and WKB
4.2. Geometry Data Type
4.2.1. PostGIS EWKB and EWKT
4.3. Geography Data Type
4.3.1. Creating Geography Tables
4.3.2. Using Geography Tables
4.3.3. When to use the Geography data type
4.3.4. Geography Advanced FAQ
4.4. Geometry Validation
4.4.1. Simple Geometry
4.4.2. Valid Geometry
4.4.3. Managing Validity
4.5. Spatial Reference Systems
4.5.1. SPATIAL_REF_SYS Table
4.5.2. User-Defined Spatial Reference Systems
4.6. Spatial Tables
4.6.1. Creating a Spatial Table
4.6.2. GEOMETRY_COLUMNS View
4.6.3. Manually Registering Geometry Columns
4.7. Loading Spatial Data
4.7.1. Using SQL to Load Data
4.7.2. Using the Shapefile Loader
4.8. Extracting Spatial Data
4.8.1. Using SQL to Extract Data
4.8.2. Using the Shapefile Dumper
4.9. Spatial Indexes
4.9.1. GiST Indexes
4.9.2. BRIN Indexes
4.9.3. SP-GiST Indexes
4.9.4. Tuning Index Usage
5. Spatial Queries
5.1. Determining Spatial Relationships
5.1.1. Dimensionally Extended 9-Intersection Model
5.1.2. Named Spatial Relationships
5.1.3. General Spatial Relationships
5.2. Using Spatial Indexes
5.3. Examples of Spatial SQL
6. Performance Tips
6.1. Small tables of large geometries
6.1.1. Problem description
6.1.2. Workarounds
6.2. CLUSTERing on geometry indices
6.3. Avoiding dimension conversion
7. PostGIS Reference
7.1. PostGIS Geometry/Geography/Box Data Types
box2d — The type representing a 2-dimensional bounding box.
box3d — The type representing a 3-dimensional bounding box.
geometry — The type representing spatial features with planar coordinate systems.
geometry_dump — A composite type used to describe the parts of complex geometry.
geography — The type representing spatial features with geodetic (ellipsoidal) coordinate systems.
7.2. Table Management Functions
AddGeometryColumn — Adds a geometry column to an existing table.
DropGeometryColumn — Removes a geometry column from a spatial table.
DropGeometryTable — Drops a table and all its references in geometry_columns.
Find_SRID — Returns the SRID defined for a geometry column.
Populate_Geometry_Columns — Ensures geometry columns are defined with type modifiers or have appropriate spatial constraints.
UpdateGeometrySRID — Updates the SRID of all features in a geometry column, and the table metadata.
7.3. Geometry Constructors
ST_Collect — Creates a GeometryCollection or Multi* geometry from a set of geometries.
ST_LineFromMultiPoint — Creates a LineString from a MultiPoint geometry.
ST_MakeEnvelope — Creates a rectangular Polygon from minimum and maximum coordinates.
ST_MakeLine — Creates a LineString from Point, MultiPoint, or LineString geometries.
ST_MakePoint — Creates a 2D, 3DZ or 4D Point.
ST_MakePointM — Creates a Point from X, Y and M values.
ST_MakePolygon — Creates a Polygon from a shell and optional list of holes.
ST_Point — Creates a Point with X, Y and SRID values.
ST_PointZ — Creates a Point with X, Y, Z and SRID values.
ST_PointM — Creates a Point with X, Y, M and SRID values.
ST_PointZM — Creates a Point with X, Y, Z, M and SRID values.
ST_Polygon — Creates a Polygon from a LineString with a specified SRID.
ST_TileEnvelope — Creates a rectangular Polygon in Web Mercator (SRID:3857) using the XYZ tile system.
ST_HexagonGrid — Returns a set of hexagons and cell indices that completely cover the bounds of the geometry argument.
ST_Hexagon — Returns a single hexagon, using the provided edge size and cell coordinate within the hexagon grid space.
ST_SquareGrid — Returns a set of grid squares and cell indices that completely cover the bounds of the geometry argument.
ST_Square — Returns a single square, using the provided edge size and cell coordinate within the square grid space.
ST_Letters — Returns the input letters rendered as geometry with a default start position at the origin and default text height of 100.
7.4. Geometry Accessors
GeometryType — Returns the type of a geometry as text.
ST_Boundary — Returns the boundary of a geometry.
ST_BoundingDiagonal — Returns the diagonal of a geometry's bounding box.
ST_CoordDim — Return the coordinate dimension of a geometry.
ST_Dimension — Returns the topological dimension of a geometry.
ST_Dump — Returns a set of geometry_dump rows for the components of a geometry.
ST_DumpPoints — Returns a set of geometry_dump rows for the coordinates in a geometry.
ST_DumpSegments — Returns a set of geometry_dump rows for the segments in a geometry.
ST_DumpRings — Returns a set of geometry_dump rows for the exterior and interior rings of a Polygon.
ST_EndPoint — Returns the last point of a LineString or CircularLineString.
ST_Envelope — Returns a geometry representing the bounding box of a geometry.
ST_ExteriorRing — Returns a LineString representing the exterior ring of a Polygon.
ST_GeometryN — Return an element of a geometry collection.
ST_GeometryType — Returns the SQL-MM type of a geometry as text.
ST_HasArc — Tests if a geometry contains a circular arc
ST_InteriorRingN — Returns the Nth interior ring (hole) of a Polygon.
ST_IsClosed — Tests if a LineStrings's start and end points are coincident. For a PolyhedralSurface tests if it is closed (volumetric).
ST_IsCollection — Tests if a geometry is a geometry collection type.
ST_IsEmpty — Tests if a geometry is empty.
ST_IsPolygonCCW — Tests if Polygons have exterior rings oriented counter-clockwise and interior rings oriented clockwise.
ST_IsPolygonCW — Tests if Polygons have exterior rings oriented clockwise and interior rings oriented counter-clockwise.
ST_IsRing — Tests if a LineString is closed and simple.
ST_IsSimple — Tests if a geometry has no points of self-intersection or self-tangency.
ST_M — Returns the M coordinate of a Point.
ST_MemSize — Returns the amount of memory space a geometry takes.
ST_NDims — Returns the coordinate dimension of a geometry.
ST_NPoints — Returns the number of points (vertices) in a geometry.
ST_NRings — Returns the number of rings in a polygonal geometry.
ST_NumGeometries — Returns the number of elements in a geometry collection.
ST_NumInteriorRings — Returns the number of interior rings (holes) of a Polygon.
ST_NumInteriorRing — Returns the number of interior rings (holes) of a Polygon. Aias for ST_NumInteriorRings
ST_NumPatches — Return the number of faces on a Polyhedral Surface. Will return null for non-polyhedral geometries.
ST_NumPoints — Returns the number of points in a LineString or CircularString.
ST_PatchN — Returns the Nth geometry (face) of a PolyhedralSurface.
ST_PointN — Returns the Nth point in the first LineString or circular LineString in a geometry.
ST_Points — Returns a MultiPoint containing the coordinates of a geometry.
ST_StartPoint — Returns the first point of a LineString.
ST_Summary — Returns a text summary of the contents of a geometry.
ST_X — Returns the X coordinate of a Point.
ST_Y — Returns the Y coordinate of a Point.
ST_Z — Returns the Z coordinate of a Point.
ST_Zmflag — Returns a code indicating the ZM coordinate dimension of a geometry.
7.5. Geometry Editors
ST_AddPoint — Add a point to a LineString.
ST_CollectionExtract — Given a geometry collection, returns a multi-geometry containing only elements of a specified type.
ST_CollectionHomogenize — Returns the simplest representation of a geometry collection.
ST_CurveToLine — Converts a geometry containing curves to a linear geometry.
ST_Scroll — Change start point of a closed LineString.
ST_FlipCoordinates — Returns a version of a geometry with X and Y axis flipped.
ST_Force2D — Force the geometries into a "2-dimensional mode".
ST_Force3D — Force the geometries into XYZ mode. This is an alias for ST_Force3DZ.
ST_Force3DZ — Force the geometries into XYZ mode.
ST_Force3DM — Force the geometries into XYM mode.
ST_Force4D — Force the geometries into XYZM mode.
ST_ForcePolygonCCW — Orients all exterior rings counter-clockwise and all interior rings clockwise.
ST_ForceCollection — Convert the geometry into a GEOMETRYCOLLECTION.
ST_ForcePolygonCW — Orients all exterior rings clockwise and all interior rings counter-clockwise.
ST_ForceSFS — Force the geometries to use SFS 1.1 geometry types only.
ST_ForceRHR — Force the orientation of the vertices in a polygon to follow the Right-Hand-Rule.
ST_ForceCurve — Upcast a geometry into its curved type, if applicable.
ST_LineToCurve — Converts a linear geometry to a curved geometry.
ST_Multi — Return the geometry as a MULTI* geometry.
ST_LineExtend — Returns a line with the last and first segments extended the specified distance(s).
ST_Normalize — Return the geometry in its canonical form.
ST_Project — Returns a point projected from a start point by a distance and bearing (azimuth).
ST_QuantizeCoordinates — Sets least significant bits of coordinates to zero
ST_RemovePoint — Remove a point from a linestring.
ST_RemoveRepeatedPoints — Returns a version of a geometry with duplicate points removed.
ST_Reverse — Return the geometry with vertex order reversed.
ST_Segmentize — Returns a modified geometry/geography having no segment longer than a given distance.
ST_SetPoint — Replace point of a linestring with a given point.
ST_ShiftLongitude — Shifts the longitude coordinates of a geometry between -180..180 and 0..360.
ST_WrapX — Wrap a geometry around an X value.
ST_SnapToGrid — Snap all points of the input geometry to a regular grid.
ST_Snap — Snap segments and vertices of input geometry to vertices of a reference geometry.
ST_SwapOrdinates — Returns a version of the given geometry with given ordinate values swapped.
7.6. Geometry Validation
ST_IsValid — Tests if a geometry is well-formed in 2D.
ST_IsValidDetail — Returns a valid_detail row stating if a geometry is valid or if not a reason and a location.
ST_IsValidReason — Returns text stating if a geometry is valid, or a reason for invalidity.
ST_MakeValid — Attempts to make an invalid geometry valid without losing vertices.
7.7. Spatial Reference System Functions
ST_InverseTransformPipeline — Return a new geometry with coordinates transformed to a different spatial reference system using the inverse of a defined coordinate transformation pipeline.
ST_SetSRID — Set the SRID on a geometry.
ST_SRID — Returns the spatial reference identifier for a geometry.
ST_Transform — Return a new geometry with coordinates transformed to a different spatial reference system.
ST_TransformPipeline — Return a new geometry with coordinates transformed to a different spatial reference system using a defined coordinate transformation pipeline.
postgis_srs_codes — Return the list of SRS codes associated with the given authority.
postgis_srs — Return a metadata record for the requested authority and srid.
postgis_srs_all — Return metadata records for every spatial reference system in the underlying Proj database.
postgis_srs_search — Return metadata records for projected coordinate systems that have areas of useage that fully contain the bounds parameter.
7.8. Geometry Input
7.8.1. Well-Known Text (WKT)
7.8.2. Well-Known Binary (WKB)
7.8.3. Other Formats
7.9. Geometry Output
7.9.1. Well-Known Text (WKT)
7.9.2. Well-Known Binary (WKB)
7.9.3. Other Formats
7.10. Operators
7.10.1. Bounding Box Operators
7.10.2. Distance Operators
7.11. Spatial Relationships
7.11.1. Topological Relationships
7.11.2. Distance Relationships
7.12. Measurement Functions
ST_Area — Returns the area of a polygonal geometry.
ST_Azimuth — Returns the north-based azimuth of a line between two points.
ST_Angle — Returns the angle between two vectors defined by 3 or 4 points, or 2 lines.
ST_ClosestPoint — Returns the 2D point on g1 that is closest to g2. This is the first point of the shortest line from one geometry to the other.
ST_3DClosestPoint — Returns the 3D point on g1 that is closest to g2. This is the first point of the 3D shortest line.
ST_Distance — Returns the distance between two geometry or geography values.
ST_3DDistance — Returns the 3D cartesian minimum distance (based on spatial ref) between two geometries in projected units.
ST_DistanceSphere — Returns minimum distance in meters between two lon/lat geometries using a spherical earth model.
ST_DistanceSpheroid — Returns the minimum distance between two lon/lat geometries using a spheroidal earth model.
ST_FrechetDistance — Returns the Fréchet distance between two geometries.
ST_HausdorffDistance — Returns the Hausdorff distance between two geometries.
ST_Length — Returns the 2D length of a linear geometry.
ST_Length2D — Returns the 2D length of a linear geometry. Alias for ST_Length
ST_3DLength — Returns the 3D length of a linear geometry.
ST_LengthSpheroid — Returns the 2D or 3D length/perimeter of a lon/lat geometry on a spheroid.
ST_LongestLine — Returns the 2D longest line between two geometries.
ST_3DLongestLine — Returns the 3D longest line between two geometries
ST_MaxDistance — Returns the 2D largest distance between two geometries in projected units.
ST_3DMaxDistance — Returns the 3D cartesian maximum distance (based on spatial ref) between two geometries in projected units.
ST_MinimumClearance — Returns the minimum clearance of a geometry, a measure of a geometry's robustness.
ST_MinimumClearanceLine — Returns the two-point LineString spanning a geometry's minimum clearance.
ST_Perimeter — Returns the length of the boundary of a polygonal geometry or geography.
ST_Perimeter2D — Returns the 2D perimeter of a polygonal geometry. Alias for ST_Perimeter.
ST_3DPerimeter — Returns the 3D perimeter of a polygonal geometry.
ST_ShortestLine — Returns the 2D shortest line between two geometries
ST_3DShortestLine — Returns the 3D shortest line between two geometries
7.13. Overlay Functions
ST_ClipByBox2D — Computes the portion of a geometry falling within a rectangle.
ST_Difference — Computes a geometry representing the part of geometry A that does not intersect geometry B.
ST_Intersection — Computes a geometry representing the shared portion of geometries A and B.
ST_MemUnion — Aggregate function which unions geometries in a memory-efficent but slower way
ST_Node — Nodes a collection of lines.
ST_Split — Returns a collection of geometries created by splitting a geometry by another geometry.
ST_Subdivide — Computes a rectilinear subdivision of a geometry.
ST_SymDifference — Computes a geometry representing the portions of geometries A and B that do not intersect.
ST_UnaryUnion — Computes the union of the components of a single geometry.
ST_Union — Computes a geometry representing the point-set union of the input geometries.
7.14. Geometry Processing
ST_Buffer — Computes a geometry covering all points within a given distance from a geometry.
ST_BuildArea — Creates a polygonal geometry formed by the linework of a geometry.
ST_Centroid — Returns the geometric center of a geometry.
ST_ChaikinSmoothing — Returns a smoothed version of a geometry, using the Chaikin algorithm
ST_ConcaveHull — Computes a possibly concave geometry that contains all input geometry vertices
ST_ConvexHull — Computes the convex hull of a geometry.
ST_DelaunayTriangles — Returns the Delaunay triangulation of the vertices of a geometry.
ST_FilterByM — Removes vertices based on their M value
ST_GeneratePoints — Generates a multipoint of random points contained in a Polygon or MultiPolygon.
ST_GeometricMedian — Returns the geometric median of a MultiPoint.
ST_LineMerge — Return the lines formed by sewing together a MultiLineString.
ST_MaximumInscribedCircle — Computes the largest circle contained within a geometry.
ST_LargestEmptyCircle — Computes the largest circle not overlapping a geometry.
ST_MinimumBoundingCircle — Returns the smallest circle polygon that contains a geometry.
ST_MinimumBoundingRadius — Returns the center point and radius of the smallest circle that contains a geometry.
ST_OrientedEnvelope — Returns a minimum-area rectangle containing a geometry.
ST_OffsetCurve — Returns an offset line at a given distance and side from an input line.
ST_PointOnSurface — Computes a point guaranteed to lie in a polygon, or on a geometry.
ST_Polygonize — Computes a collection of polygons formed from the linework of a set of geometries.
ST_ReducePrecision — Returns a valid geometry with points rounded to a grid tolerance.
ST_SharedPaths — Returns a collection containing paths shared by the two input linestrings/multilinestrings.
ST_Simplify — Returns a simplified version of a geometry, using the Douglas-Peucker algorithm.
ST_SimplifyPreserveTopology — Returns a simplified and valid version of a geometry, using the Douglas-Peucker algorithm.
ST_SimplifyPolygonHull — Computes a simplifed topology-preserving outer or inner hull of a polygonal geometry.
ST_SimplifyVW — Returns a simplified version of a geometry, using the Visvalingam-Whyatt algorithm
ST_SetEffectiveArea — Sets the effective area for each vertex, using the Visvalingam-Whyatt algorithm.
ST_TriangulatePolygon — Computes the constrained Delaunay triangulation of polygons
ST_VoronoiLines — Returns the boundaries of the Voronoi diagram of the vertices of a geometry.
ST_VoronoiPolygons — Returns the cells of the Voronoi diagram of the vertices of a geometry.
7.15. Coverages
ST_CoverageInvalidEdges — Window function that finds locations where polygons fail to form a valid coverage.
ST_CoverageSimplify — Window function that simplifies the edges of a polygonal coverage.
ST_CoverageUnion — Computes the union of a set of polygons forming a coverage by removing shared edges.
7.16. Affine Transformations
ST_Affine — Apply a 3D affine transformation to a geometry.
ST_Rotate — Rotates a geometry about an origin point.
ST_RotateX — Rotates a geometry about the X axis.
ST_RotateY — Rotates a geometry about the Y axis.
ST_RotateZ — Rotates a geometry about the Z axis.
ST_Scale — Scales a geometry by given factors.
ST_Translate — Translates a geometry by given offsets.
ST_TransScale — Translates and scales a geometry by given offsets and factors.
7.17. Clustering Functions
ST_ClusterDBSCAN — Window function that returns a cluster id for each input geometry using the DBSCAN algorithm.
ST_ClusterIntersecting — Aggregate function that clusters input geometries into connected sets.
ST_ClusterIntersectingWin — Window function that returns a cluster id for each input geometry, clustering input geometries into connected sets.
ST_ClusterKMeans — Window function that returns a cluster id for each input geometry using the K-means algorithm.
ST_ClusterWithin — Aggregate function that clusters geometries by separation distance.
ST_ClusterWithinWin — Window function that returns a cluster id for each input geometry, clustering using separation distance.
7.18. Bounding Box Functions
Box2D — Returns a BOX2D representing the 2D extent of a geometry.
Box3D — Returns a BOX3D representing the 3D extent of a geometry.
ST_EstimatedExtent — Returns the estimated extent of a spatial table.
ST_Expand — Returns a bounding box expanded from another bounding box or a geometry.
ST_Extent — Aggregate function that returns the bounding box of geometries.
ST_3DExtent — Aggregate function that returns the 3D bounding box of geometries.
ST_MakeBox2D — Creates a BOX2D defined by two 2D point geometries.
ST_3DMakeBox — Creates a BOX3D defined by two 3D point geometries.
ST_XMax — Returns the X maxima of a 2D or 3D bounding box or a geometry.
ST_XMin — Returns the X minima of a 2D or 3D bounding box or a geometry.
ST_YMax — Returns the Y maxima of a 2D or 3D bounding box or a geometry.
ST_YMin — Returns the Y minima of a 2D or 3D bounding box or a geometry.
ST_ZMax — Returns the Z maxima of a 2D or 3D bounding box or a geometry.
ST_ZMin — Returns the Z minima of a 2D or 3D bounding box or a geometry.
7.19. Linear Referencing
ST_LineInterpolatePoint — Returns a point interpolated along a line at a fractional location.
ST_3DLineInterpolatePoint — Returns a point interpolated along a 3D line at a fractional location.
ST_LineInterpolatePoints — Returns points interpolated along a line at a fractional interval.
ST_LineLocatePoint — Returns the fractional location of the closest point on a line to a point.
ST_LineSubstring — Returns the part of a line between two fractional locations.
ST_LocateAlong — Returns the point(s) on a geometry that match a measure value.
ST_LocateBetween — Returns the portions of a geometry that match a measure range.
ST_LocateBetweenElevations — Returns the portions of a geometry that lie in an elevation (Z) range.
ST_InterpolatePoint — Returns the interpolated measure of a geometry closest to a point.
ST_AddMeasure — Interpolates measures along a linear geometry.
7.20. Trajectory Functions
ST_IsValidTrajectory — Tests if the geometry is a valid trajectory.
ST_ClosestPointOfApproach — Returns a measure at the closest point of approach of two trajectories.
ST_DistanceCPA — Returns the distance between the closest point of approach of two trajectories.
ST_CPAWithin — Tests if the closest point of approach of two trajectories is within the specified distance.
7.21. SFCGAL Functions
postgis_sfcgal_version — Returns the version of SFCGAL in use
postgis_sfcgal_full_version — Returns the full version of SFCGAL in use including CGAL and Boost versions
ST_3DArea — Computes area of 3D surface geometries. Will return 0 for solids.
ST_3DConvexHull — Computes the 3D convex hull of a geometry.
ST_3DIntersection — Perform 3D intersection
ST_3DDifference — Perform 3D difference
ST_3DUnion — Perform 3D union.
ST_AlphaShape — Computes an Alpha-shape enclosing a geometry
ST_ApproximateMedialAxis — Compute the approximate medial axis of an areal geometry.
ST_ConstrainedDelaunayTriangles — Return a constrained Delaunay triangulation around the given input geometry.
ST_Extrude — Extrude a surface to a related volume
ST_ForceLHR — Force LHR orientation
ST_IsPlanar — Check if a surface is or not planar
ST_IsSolid — Test if the geometry is a solid. No validity check is performed.
ST_MakeSolid — Cast the geometry into a solid. No check is performed. To obtain a valid solid, the input geometry must be a closed Polyhedral Surface or a closed TIN.
ST_MinkowskiSum — Performs Minkowski sum
ST_OptimalAlphaShape — Computes an Alpha-shape enclosing a geometry using an "optimal" alpha value.
ST_Orientation — Determine surface orientation
ST_StraightSkeleton — Compute a straight skeleton from a geometry
ST_Tesselate — Perform surface Tesselation of a polygon or polyhedralsurface and returns as a TIN or collection of TINS
ST_Volume — Computes the volume of a 3D solid. If applied to surface (even closed) geometries will return 0.
7.22. Long Transaction Support
AddAuth — Adds an authorization token to be used in the current transaction.
CheckAuth — Creates a trigger on a table to prevent/allow updates and deletes of rows based on authorization token.
DisableLongTransactions — Disables long transaction support.
EnableLongTransactions — Enables long transaction support.
LockRow — Sets lock/authorization for a row in a table.
UnlockRows — Removes all locks held by an authorization token.
7.23. Version Functions
PostGIS_Extensions_Upgrade — Packages and upgrades PostGIS extensions (e.g. postgis_raster, postgis_topology, postgis_sfcgal) to given or latest version.
PostGIS_Full_Version — Reports full PostGIS version and build configuration infos.
PostGIS_GEOS_Version — Returns the version number of the GEOS library.
PostGIS_GEOS_Compiled_Version — Returns the version number of the GEOS library against which PostGIS was built.
PostGIS_Liblwgeom_Version — Returns the version number of the liblwgeom library. This should match the version of PostGIS.
PostGIS_LibXML_Version — Returns the version number of the libxml2 library.
PostGIS_Lib_Build_Date — Returns build date of the PostGIS library.
PostGIS_Lib_Version — Returns the version number of the PostGIS library.
PostGIS_PROJ_Version — Returns the version number of the PROJ4 library.
PostGIS_Wagyu_Version — Returns the version number of the internal Wagyu library.
PostGIS_Scripts_Build_Date — Returns build date of the PostGIS scripts.
PostGIS_Scripts_Installed — Returns version of the PostGIS scripts installed in this database.
PostGIS_Scripts_Released — Returns the version number of the postgis.sql script released with the installed PostGIS lib.
PostGIS_Version — Returns PostGIS version number and compile-time options.
7.24. Grand Unified Custom Variables (GUCs)
postgis.backend — The backend to service a function where GEOS and SFCGAL overlap. Options: geos or sfcgal. Defaults to geos.
postgis.gdal_datapath — A configuration option to assign the value of GDAL's GDAL_DATA option. If not set, the environmentally set GDAL_DATA variable is used.
postgis.gdal_enabled_drivers — A configuration option to set the enabled GDAL drivers in the PostGIS environment. Affects the GDAL configuration variable GDAL_SKIP.
postgis.enable_outdb_rasters — A boolean configuration option to enable access to out-db raster bands.
postgis.gdal_config_options — A string configuration to set options used when working with an out-db raster.
7.25. Troubleshooting Functions
PostGIS_AddBBox — Add bounding box to the geometry.
PostGIS_DropBBox — Drop the bounding box cache from the geometry.
PostGIS_HasBBox — Returns TRUE if the bbox of this geometry is cached, FALSE otherwise.
8. Topology
8.1. Topology Types
getfaceedges_returntype — A composite type that consists of a sequence number and an edge number.
TopoGeometry — A composite type representing a topologically defined geometry.
validatetopology_returntype — A composite type that consists of an error message and id1 and id2 to denote location of error. This is the return type for ValidateTopology.
8.2. Topology Domains
TopoElement — An array of 2 integers generally used to identify a TopoGeometry component.
TopoElementArray — An array of TopoElement objects.
8.3. Topology and TopoGeometry Management
AddTopoGeometryColumn — Adds a topogeometry column to an existing table, registers this new column as a layer in topology.layer and returns the new layer_id.
RenameTopoGeometryColumn — Renames a topogeometry column
DropTopology — Use with caution: Drops a topology schema and deletes its reference from topology.topology table and references to tables in that schema from the geometry_columns table.
RenameTopology — Renames a topology
DropTopoGeometryColumn — Drops the topogeometry column from the table named table_name in schema schema_name and unregisters the columns from topology.layer table.
Populate_Topology_Layer — Adds missing entries to topology.layer table by reading metadata from topo tables.
TopologySummary — Takes a topology name and provides summary totals of types of objects in topology.
ValidateTopology — Returns a set of validatetopology_returntype objects detailing issues with topology.
ValidateTopologyRelation — Returns info about invalid topology relation records
FindTopology — Returns a topology record by different means.
FindLayer — Returns a topology.layer record by different means.
8.4. Topology Statistics Management
8.5. Topology Constructors
CreateTopology — Creates a new topology schema and registers it in the topology.topology table.
CopyTopology — Makes a copy of a topology (nodes, edges, faces, layers and TopoGeometries) into a new schema
ST_InitTopoGeo — Creates a new topology schema and registers it in the topology.topology table.
ST_CreateTopoGeo — Adds a collection of geometries to a given empty topology and returns a message detailing success.
TopoGeo_AddPoint — Adds a point to an existing topology using a tolerance and possibly splitting an existing edge.
TopoGeo_AddLineString — Adds a linestring to an existing topology using a tolerance and possibly splitting existing edges/faces. Returns edge identifiers.
TopoGeo_AddPolygon — Adds a polygon to an existing topology using a tolerance and possibly splitting existing edges/faces. Returns face identifiers.
8.6. Topology Editors
ST_AddIsoNode — Adds an isolated node to a face in a topology and returns the nodeid of the new node. If face is null, the node is still created.
ST_AddIsoEdge — Adds an isolated edge defined by geometry alinestring to a topology connecting two existing isolated nodes anode and anothernode and returns the edge id of the new edge.
ST_AddEdgeNewFaces — Add a new edge and, if in doing so it splits a face, delete the original face and replace it with two new faces.
ST_AddEdgeModFace — Add a new edge and, if in doing so it splits a face, modify the original face and add a new face.
ST_RemEdgeNewFace — Removes an edge and, if the removed edge separated two faces, delete the original faces and replace them with a new face.
ST_RemEdgeModFace — Removes an edge, and if the edge separates two faces deletes one face and modifies the other face to cover the space of both.
ST_ChangeEdgeGeom — Changes the shape of an edge without affecting the topology structure.
ST_ModEdgeSplit — Split an edge by creating a new node along an existing edge, modifying the original edge and adding a new edge.
ST_ModEdgeHeal — Heals two edges by deleting the node connecting them, modifying the first edge and deleting the second edge. Returns the id of the deleted node.
ST_NewEdgeHeal — Heals two edges by deleting the node connecting them, deleting both edges, and replacing them with an edge whose direction is the same as the first edge provided.
ST_MoveIsoNode — Moves an isolated node in a topology from one point to another. If new apoint geometry exists as a node an error is thrown. Returns description of move.
ST_NewEdgesSplit — Split an edge by creating a new node along an existing edge, deleting the original edge and replacing it with two new edges. Returns the id of the new node created that joins the new edges.
ST_RemoveIsoNode — Removes an isolated node and returns description of action. If the node is not isolated (is start or end of an edge), then an exception is thrown.
ST_RemoveIsoEdge — Removes an isolated edge and returns description of action. If the edge is not isolated, then an exception is thrown.
8.7. Topology Accessors
GetEdgeByPoint — Finds the edge-id of an edge that intersects a given point.
GetFaceByPoint — Finds face intersecting a given point.
GetFaceContainingPoint — Finds the face containing a point.
GetNodeByPoint — Finds the node-id of a node at a point location.
GetTopologyID — Returns the id of a topology in the topology.topology table given the name of the topology.
GetTopologySRID — Returns the SRID of a topology in the topology.topology table given the name of the topology.
GetTopologyName — Returns the name of a topology (schema) given the id of the topology.
ST_GetFaceEdges — Returns a set of ordered edges that bound aface.
ST_GetFaceGeometry — Returns the polygon in the given topology with the specified face id.
GetRingEdges — Returns the ordered set of signed edge identifiers met by walking on an a given edge side.
GetNodeEdges — Returns an ordered set of edges incident to the given node.
8.8. Topology Processing
Polygonize — Finds and registers all faces defined by topology edges.
AddNode — Adds a point node to the node table in the specified topology schema and returns the nodeid of new node. If point already exists as node, the existing nodeid is returned.
AddEdge — Adds a linestring edge to the edge table and associated start and end points to the point nodes table of the specified topology schema using the specified linestring geometry and returns the edgeid of the new (or existing) edge.
AddFace — Registers a face primitive to a topology and gets its identifier.
ST_Simplify — Returns a "simplified" geometry version of the given TopoGeometry using the Douglas-Peucker algorithm.
RemoveUnusedPrimitives — Removes topology primitives which not needed to define existing TopoGeometry objects.
8.9. TopoGeometry Constructors
CreateTopoGeom — Creates a new topo geometry object from topo element array - tg_type: 1:[multi]point, 2:[multi]line, 3:[multi]poly, 4:collection
toTopoGeom — Converts a simple Geometry into a topo geometry.
TopoElementArray_Agg — Returns a topoelementarray for a set of element_id, type arrays (topoelements).
TopoElement — Converts a topogeometry to a topoelement.
8.10. TopoGeometry Editors
clearTopoGeom — Clears the content of a topo geometry.
TopoGeom_addElement — Adds an element to the definition of a TopoGeometry.
TopoGeom_remElement — Removes an element from the definition of a TopoGeometry.
TopoGeom_addTopoGeom — Adds element of a TopoGeometry to the definition of another TopoGeometry.
toTopoGeom — Adds a geometry shape to an existing topo geometry.
8.11. TopoGeometry Accessors
GetTopoGeomElementArray — Returns a topoelementarray (an array of topoelements) containing the topological elements and type of the given TopoGeometry (primitive elements).
GetTopoGeomElements — Returns a set of topoelement objects containing the topological element_id,element_type of the given TopoGeometry (primitive elements).
ST_SRID — Returns the spatial reference identifier for a topogeometry.
8.12. TopoGeometry Outputs
AsGML — Returns the GML representation of a topogeometry.
AsTopoJSON — Returns the TopoJSON representation of a topogeometry.
8.13. Topology Spatial Relationships
Equals — Returns true if two topogeometries are composed of the same topology primitives.
Intersects — Returns true if any pair of primitives from the two topogeometries intersect.
8.14. Importing and exporting Topologies
8.14.1. Using the Topology exporter
8.14.2. Using the Topology importer
9. Raster Data Management, Queries, and Applications
9.1. Loading and Creating Rasters
9.1.1. Using raster2pgsql to load rasters
9.1.2. Creating rasters using PostGIS raster functions
9.1.3. Using "out db" cloud rasters
9.2. Raster Catalogs
9.2.1. Raster Columns Catalog
9.2.2. Raster Overviews
9.3. Building Custom Applications with PostGIS Raster
9.3.1. PHP Example Outputting using ST_AsPNG in concert with other raster functions
9.3.2. ASP.NET C# Example Outputting using ST_AsPNG in concert with other raster functions
9.3.3. Java console app that outputs raster query as Image file
9.3.4. Use PLPython to dump out images via SQL
9.3.5. Outputting Rasters with PSQL
10. Raster Reference
10.1. Raster Support Data types
geomval — A spatial datatype with two fields - geom (holding a geometry object) and val (holding a double precision pixel value from a raster band).
addbandarg — A composite type used as input into the ST_AddBand function defining the attributes and initial value of the new band.
rastbandarg — A composite type for use when needing to express a raster and a band index of that raster.
raster — raster spatial data type.
reclassarg — A composite type used as input into the ST_Reclass function defining the behavior of reclassification.
summarystats — A composite type returned by the ST_SummaryStats and ST_SummaryStatsAgg functions.
unionarg — A composite type used as input into the ST_Union function defining the bands to be processed and behavior of the UNION operation.
10.2. Raster Management
AddRasterConstraints — Adds raster constraints to a loaded raster table for a specific column that constrains spatial ref, scaling, blocksize, alignment, bands, band type and a flag to denote if raster column is regularly blocked. The table must be loaded with data for the constraints to be inferred. Returns true if the constraint setting was accomplished and issues a notice otherwise.
DropRasterConstraints — Drops PostGIS raster constraints that refer to a raster table column. Useful if you need to reload data or update your raster column data.
AddOverviewConstraints — Tag a raster column as being an overview of another.
DropOverviewConstraints — Untag a raster column from being an overview of another.
PostGIS_GDAL_Version — Reports the version of the GDAL library in use by PostGIS.
PostGIS_Raster_Lib_Build_Date — Reports full raster library build date.
PostGIS_Raster_Lib_Version — Reports full raster version and build configuration infos.
ST_GDALDrivers — Returns a list of raster formats supported by PostGIS through GDAL. Only those formats with can_write=True can be used by ST_AsGDALRaster
ST_Contour — Generates a set of vector contours from the provided raster band, using the GDAL contouring algorithm.
ST_InterpolateRaster — Interpolates a gridded surface based on an input set of 3-d points, using the X- and Y-values to position the points on the grid and the Z-value of the points as the surface elevation.
UpdateRasterSRID — Change the SRID of all rasters in the user-specified column and table.
ST_CreateOverview — Create an reduced resolution version of a given raster coverage.
10.3. Raster Constructors
ST_AddBand — Returns a raster with the new band(s) of given type added with given initial value in the given index location. If no index is specified, the band is added to the end.
ST_AsRaster — Converts a PostGIS geometry to a PostGIS raster.
ST_Band — Returns one or more bands of an existing raster as a new raster. Useful for building new rasters from existing rasters.
ST_MakeEmptyCoverage — Cover georeferenced area with a grid of empty raster tiles.
ST_MakeEmptyRaster — Returns an empty raster (having no bands) of given dimensions (width & height), upperleft X and Y, pixel size and rotation (scalex, scaley, skewx & skewy) and reference system (srid). If a raster is passed in, returns a new raster with the same size, alignment and SRID. If srid is left out, the spatial ref is set to unknown (0).
ST_Tile — Returns a set of rasters resulting from the split of the input raster based upon the desired dimensions of the output rasters.
ST_Retile — Return a set of configured tiles from an arbitrarily tiled raster coverage.
ST_FromGDALRaster — Returns a raster from a supported GDAL raster file.
10.4. Raster Accessors
ST_GeoReference — Returns the georeference meta data in GDAL or ESRI format as commonly seen in a world file. Default is GDAL.
ST_Height — Returns the height of the raster in pixels.
ST_IsEmpty — Returns true if the raster is empty (width = 0 and height = 0). Otherwise, returns false.
ST_MemSize — Returns the amount of space (in bytes) the raster takes.
ST_MetaData — Returns basic meta data about a raster object such as pixel size, rotation (skew), upper, lower left, etc.
ST_NumBands — Returns the number of bands in the raster object.
ST_PixelHeight — Returns the pixel height in geometric units of the spatial reference system.
ST_PixelWidth — Returns the pixel width in geometric units of the spatial reference system.
ST_ScaleX — Returns the X component of the pixel width in units of coordinate reference system.
ST_ScaleY — Returns the Y component of the pixel height in units of coordinate reference system.
ST_RasterToWorldCoord — Returns the raster's upper left corner as geometric X and Y (longitude and latitude) given a column and row. Column and row starts at 1.
ST_RasterToWorldCoordX — Returns the geometric X coordinate upper left of a raster, column and row. Numbering of columns and rows starts at 1.
ST_RasterToWorldCoordY — Returns the geometric Y coordinate upper left corner of a raster, column and row. Numbering of columns and rows starts at 1.
ST_Rotation — Returns the rotation of the raster in radian.
ST_SkewX — Returns the georeference X skew (or rotation parameter).
ST_SkewY — Returns the georeference Y skew (or rotation parameter).
ST_SRID — Returns the spatial reference identifier of the raster as defined in spatial_ref_sys table.
ST_Summary — Returns a text summary of the contents of the raster.
ST_UpperLeftX — Returns the upper left X coordinate of raster in projected spatial ref.
ST_UpperLeftY — Returns the upper left Y coordinate of raster in projected spatial ref.
ST_Width — Returns the width of the raster in pixels.
ST_WorldToRasterCoord — Returns the upper left corner as column and row given geometric X and Y (longitude and latitude) or a point geometry expressed in the spatial reference coordinate system of the raster.
ST_WorldToRasterCoordX — Returns the column in the raster of the point geometry (pt) or a X and Y world coordinate (xw, yw) represented in world spatial reference system of raster.
ST_WorldToRasterCoordY — Returns the row in the raster of the point geometry (pt) or a X and Y world coordinate (xw, yw) represented in world spatial reference system of raster.
10.5. Raster Band Accessors
ST_BandMetaData — Returns basic meta data for a specific raster band. band num 1 is assumed if none-specified.
ST_BandNoDataValue — Returns the value in a given band that represents no data. If no band num 1 is assumed.
ST_BandIsNoData — Returns true if the band is filled with only nodata values.
ST_BandPath — Returns system file path to a band stored in file system. If no bandnum specified, 1 is assumed.
ST_BandFileSize — Returns the file size of a band stored in file system. If no bandnum specified, 1 is assumed.
ST_BandFileTimestamp — Returns the file timestamp of a band stored in file system. If no bandnum specified, 1 is assumed.
ST_BandPixelType — Returns the type of pixel for given band. If no bandnum specified, 1 is assumed.
ST_MinPossibleValue — Returns the minimum value this pixeltype can store.
ST_HasNoBand — Returns true if there is no band with given band number. If no band number is specified, then band number 1 is assumed.
10.6. Raster Pixel Accessors and Setters
ST_PixelAsPolygon — Returns the polygon geometry that bounds the pixel for a particular row and column.
ST_PixelAsPolygons — Returns the polygon geometry that bounds every pixel of a raster band along with the value, the X and the Y raster coordinates of each pixel.
ST_PixelAsPoint — Returns a point geometry of the pixel's upper-left corner.
ST_PixelAsPoints — Returns a point geometry for each pixel of a raster band along with the value, the X and the Y raster coordinates of each pixel. The coordinates of the point geometry are of the pixel's upper-left corner.
ST_PixelAsCentroid — Returns the centroid (point geometry) of the area represented by a pixel.
ST_PixelAsCentroids — Returns the centroid (point geometry) for each pixel of a raster band along with the value, the X and the Y raster coordinates of each pixel. The point geometry is the centroid of the area represented by a pixel.
ST_Value — Returns the value of a given band in a given columnx, rowy pixel or at a particular geometric point. Band numbers start at 1 and assumed to be 1 if not specified. If exclude_nodata_value is set to false, then all pixels include nodata pixels are considered to intersect and return value. If exclude_nodata_value is not passed in then reads it from metadata of raster.
ST_NearestValue — Returns the nearest non-NODATA value of a given band's pixel specified by a columnx and rowy or a geometric point expressed in the same spatial reference coordinate system as the raster.
ST_SetZ — Returns a geometry with the same X/Y coordinates as the input geometry, and values from the raster copied into the Z dimension using the requested resample algorithm.
ST_SetM — Returns a geometry with the same X/Y coordinates as the input geometry, and values from the raster copied into the M dimension using the requested resample algorithm.
ST_Neighborhood — Returns a 2-D double precision array of the non-NODATA values around a given band's pixel specified by either a columnX and rowY or a geometric point expressed in the same spatial reference coordinate system as the raster.
ST_SetValue — Returns modified raster resulting from setting the value of a given band in a given columnx, rowy pixel or the pixels that intersect a particular geometry. Band numbers start at 1 and assumed to be 1 if not specified.
ST_SetValues — Returns modified raster resulting from setting the values of a given band.
ST_DumpValues — Get the values of the specified band as a 2-dimension array.
ST_PixelOfValue — Get the columnx, rowy coordinates of the pixel whose value equals the search value.
10.7. Raster Editors
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.
~= — Returns TRUE if A's bounding box is the same as B's.
~ — 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 Extras
11.1. Address Standardizer
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