Chapter 7. Manual de Referencia PostGIS

Table of Contents

Las siguientes funciones son las que probablemente necesite un usuario PortGIS . Existen otras funciones de soporte necesarias para los objetos PostGIS que no se usan por la mayoría de usuarios.

[Note]

PostGIS ha comenzado una transición de la convención de nomenclatura existente, a una convención SQL-MM-céntrica. Como resultado, la mayoría de las funciones que conoces y adoras han sido renombradas usando el prefijo espacial estándar (ST). Funciones anteriores están todavía disponibles, aunque no se enumeran en este documento donde las funciones actualizadas son equivalentes. Las funciones no st_ no mencionadas en esta documentación están en desuso y se eliminarán en una versión futura de modo que DEJA DE UTILIZARLAS.

7.1. Tipos Geometry/Geography/Box en PostgreSQL PostGIS

Abstract

Esta sección detalla los tipos de dato de PostgreSQL instalados por PostGIS. Note que describimos el comportamiento de la conversión de tipos en los casos en los que es muy importante, especialmente cuando se diseñe sis propias funciones.

Each data type describes its type casting behavior. A type cast converts values of one data type into another type. PostgreSQL allows defining casting behavior for custom types, along with the functions used to convert type values. Casts can have automatic behavior, which allows automatic conversion of a function argument to a type supported by the function.

Some casts have explicit behavior, which means the cast must be specified using the syntax CAST(myval As sometype) or myval::sometype. Explicit casting avoids the issue of ambiguous casts, which can occur when using an overloaded function which does not support a given type. For example, a function may accept a box2d or a box3d, but not a geometry. Since geometry has an automatic cast to both box types, this produces an "ambiguous function" error. To prevent the error use an explicit cast to the desired box type.

All data types can be cast to text, so this does not need to be specified explicitly.

  • box2d — The type representing a 2-dimensional bounding box.
  • box3d — The type representing a 3-dimensional bounding box.
  • geometry — geography es un tipo de dato espacial usado para representar una feature en un sistema de coordenadas de Tierra esférica.
  • 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. Funciones de Gestión

Abstract

These functions assist in defining tables containing geometry columns.

  • AddGeometryColumn — Suprime una columna de geometrías de una tabla espacial.
  • DropGeometryColumn — Suprime una columna de geometrías de una tabla espacial.
  • DropGeometryTable — Borra una tabla y todas sus referencias en la tabla geómetra_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. Contructores Geométricos

  • ST_Collect — Creates a GeometryCollection or Multi* geometry from a set of geometries.
  • ST_LineFromMultiPoint — Crea una LineString desde una geometría MultiPoint.
  • ST_MakeEnvelope — Crea un polígono rectangular formado a partir de los mínimos y máximos especificados. Los valores de entrada deben estar en el SRS especificado en el SRID.
  • ST_MakeLine — Crea una cadena de línea desde geometrías de punto, multipunto o de línea.
  • ST_MakePoint — Creates a 2D, 3DZ or 4D Point.
  • ST_MakePointM — Crea un punto con coordenadas x, y y un valor de medida.
  • 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. Métodos de Acceso a Geometrías

  • GeometryType — Devuelve el tipo de geometría del valor de ST_Geometry.
  • ST_Boundary — Devuelve el cierre del limite combinatorio de esta geometría.
  • ST_BoundingDiagonal — Devuelve la diagonal del cuadro delimitador de la geometría suministrada.
  • ST_CoordDim — Devuelve la dimensión de las coordenadas del valor de ST_Geometry.
  • ST_Dimension — Devuelve la dimensión de las coordenadas del valor de ST_Geometry.
  • ST_Dump — Returns a set of geometry_dump rows for the components of a geometry.
  • ST_DumpPoints — Devuelve un conjunto de geometry_dump filas para las coordenadas de una geometría.
  • ST_DumpSegments — Devuelve un conjunto de geometry_dump filas para los segmentos de una geometría.
  • ST_DumpRings — Returns a set of geometry_dump rows for the exterior and interior rings of a Polygon.
  • ST_EndPoint — Devuelve el número de puntos en un valor ST_LineString o ST_CircularString.
  • ST_Envelope — Devuelve una geometría que representa la caja en doble precisión (float8) de la geometría dada.
  • ST_ExteriorRing — Devuelva el número de anillos interiores de una geometría poligonal.
  • ST_GeometryN — Devuelve el tipo de geometría del valor de ST_Geometry.
  • ST_GeometryType — Devuelve el tipo de geometría del valor de ST_Geometry.
  • ST_HasArc — Tests if a geometry contains a circular arc
  • ST_InteriorRingN — Devuelva el número de anillos interiores de una geometría poligonal.
  • ST_NumCurves — Return the number of component curves in a CompoundCurve.
  • ST_CurveN — Returns the Nth component curve geometry of a CompoundCurve.
  • ST_IsClosed — Devuelve TRUE si los puntos de inicio y final de una LINESTRINGson coincidentes. Para superficies poliedricas si son cerradas (volumetricas).
  • ST_IsCollection — Devuelve True si la Geometría es una colección vacía, polígono vacio, punto vacío etc.
  • ST_IsEmpty — Tests if a geometry is empty.
  • ST_IsPolygonCCW — Devuelve true si todos los aros exteriores están orientados hacia la izquierda y todos los aros interiores están orientados hacia la derecha.
  • ST_IsPolygonCW — Devuelve true si todos los aros exteriores están orientados hacia la derecha y todos los aros interiores están orientados en sentido contrario a las agujas del reloj.
  • ST_IsRing — Tests if a LineString is closed and simple.
  • ST_IsSimple — Devuelve (TRUE) si la geometría no tiene puntos geométricos anómalos, como auto intersecciones o tangencias.
  • ST_M — Returns the M coordinate of a Point.
  • ST_MemSize — Devuelve el tipo de geometría del valor de ST_Geometry.
  • ST_NDims — Devuelve la dimensión de las coordenadas del valor de ST_Geometry.
  • ST_NPoints — Devuelve el numero de puntos (vértices) en la geometría.
  • ST_NRings — Devuelva el número de anillos interiores de una geometría poligonal.
  • ST_NumGeometries — Devuelve el numero de puntos en la geometría. Funciona con todas las geometrías.
  • ST_NumInteriorRings — Devuelva el número de anillos interiores de una geometría poligonal.
  • ST_NumInteriorRing — Devuelve el número de anillos interiores de un polígono en la geometría. Sinónimo de ST_NumInteriorRings.
  • ST_NumPatches — Devuelve el número de caras en una superficie poliédrica. Devolverá nulo para geometrías no poliédricas.
  • ST_NumPoints — Devuelve el número de puntos en un valor ST_LineString o ST_CircularString.
  • ST_PatchN — Devuelve el tipo de geometría del valor de ST_Geometry.
  • ST_PointN — Devuelve el número de puntos en un valor ST_LineString o ST_CircularString.
  • ST_Points — Devuelve un MultiPoint que contiene todas las coordenadas de una geometría.
  • ST_StartPoint — Returns the first point of a LineString.
  • ST_Summary — Devuelve un resumen de texto del contenido de la geometría.
  • 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 — Devuelve la dimensión de las coordenadas del valor de ST_Geometry.
  • ST_HasZ — Checks if a geometry has a Z dimension.
  • ST_HasM — Checks if a geometry has an M (measure) dimension.

7.5. Editores de Geometría

Abstract

These functions create modified geometries by changing type, structure or vertices.

  • ST_AddPoint — Añade un punto a una cadena de línea.
  • 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 — Forzar las geometrías en un "modo de 2 dimensiones".
  • ST_Force3D — Forzar las geometrías en modo XYZ. Este es un alias para ST_Force3DZ.
  • ST_Force3DZ — Fuerza las geometrías en modo XYZ.
  • ST_Force3DM — Fuerza las geometrías en modo XYM.
  • ST_Force4D — Fuerza las geometrías en modo XYZM.
  • ST_ForceCollection — Convertir la geometría en una GEOMETRYCOLLECTION.
  • ST_ForceCurve — Relanzar una geometría en su tipo curvo, si corresponde.
  • ST_ForcePolygonCCW — Orienta todos los aros exteriores en sentido contrario a las agujas del reloj y todos los aros interiores en sentido horario.
  • ST_ForcePolygonCW — Orienta todos los anillos exteriores en el sentido de las agujas del reloj y todos los anillos interiores en sentido contrario a las agujas del reloj.
  • ST_ForceSFS — Fuerza las geometrías para usar sólo los tipos de geometría SFS 1.1.
  • ST_ForceRHR — Fuerza la orientación de los vértices en un polígono para seguir la regla de la mano derecha.
  • ST_LineExtend — Returns a line extended forwards and backwards by specified distances.
  • ST_LineToCurve — Converts a linear geometry to a curved geometry.
  • ST_Multi — Devuelve la geometría como una geometría MULTI*.
  • ST_Normalize — Devuelve la geometría en su forma canónica.
  • 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 — Devuelve la geometría con el orden de vértice invertido.
  • ST_Segmentize — Returns a modified geometry/geography having no segment longer than a given distance.
  • ST_SetPoint — Reemplace el punto de una cadena de línea con un punto dado.
  • 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 — Ajusta todos los puntos de la geometría de entrada a una cuadrícula regular.
  • ST_Snap — Ajusta segmentos y vértices de la geometría de entrada a vértices de una geometría de referencia.
  • ST_SwapOrdinates — Returns a version of the given geometry with given ordinate values swapped.

7.6. Geometry Validation

Abstract

These functions test whether geometries are valid according to the OGC SFS standard. They also provide information about the nature and location of invalidity. There is also a function to create a valid geometry out of an invalid one.

  • 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

Abstract

These functions work with the Spatial Reference System of geometries as defined in the spatial_ref_sys table.

  • 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

Abstract

These functions create geometry objects from various textual or binary formats.

7.8.1. Well-Known Text (WKT)

  • ST_BdPolyFromText — Construye un polígono dando una colección arbitraria de cadenas de líneas cerradas como representación "MultiLineString" de texto "Well-Known".
  • ST_BdMPolyFromText — Construye un multipolígono dando una colección arbitraria de cadenas de líneas cerradas como representación "MultiLineString" de texto "Well-Known".
  • ST_GeogFromText — Devuelve un valor especifico "geography" desde una representación "Well-Known Text" (WKT) o extendida.
  • ST_GeographyFromText — Devuelve un valor especifico "geography" desde una representación "Well-Known Text" (WKT) o extendida.
  • ST_GeomCollFromText — Hace una colección Geometry de la colección WKT con el SRID dado. Si no se da SRID, el valor predeterminado es 0.
  • ST_GeomFromEWKT — Devuelve un valor especificado ST_Geometry desde una representación "Extended Well-Known Text" (EWKT).
  • ST_GeomFromMARC21 — Takes MARC21/XML geographic data as input and returns a PostGIS geometry object.
  • ST_GeometryFromText — Devuelve un valor especifico de ST_Geometry desde una representación "Well-Known Text" (WKT). Es un alias para ST_GeomFromText
  • ST_GeomFromText — Devuelve un valor especifico de ST_Geometry desde una representación "Extended Well-Known Binary" (EWKB).
  • ST_LineFromText — Hace una geometría de la representación WKT con el SRID dado. Si SRID no se da, el valor predeterminado es 0.
  • ST_MLineFromText — Devuelve un valor especificado ST_MultiLineString desde una representación WKT.
  • ST_MPointFromText — Hace una geometría desde un WKT con el SRID dado. Si no se da un SRID, el valor predeterminado es 0.
  • ST_MPolyFromText — Hace una Geometría MultiPolygon desde un WKT con el SRID dado. Si no se da SRID, el valor predeterminado es 0.
  • ST_PointFromText — Crea una geometría puntual desde un WKT con el SRID dado. Si no se especifica el SRID por defecto será unknown.
  • ST_PolygonFromText — Hace una geometría desde un WKT con el SRID dado. Si no se da un SRID, el valor predeterminado es 0.
  • ST_WKTToSQL — Devuelve un valor especifico de ST_Geometry desde una representación "Well-Known Text" (WKT). Es un alias para ST_GeomFromText

7.8.2. Well-Known Binary (WKB)

  • ST_GeogFromWKB — Crea una instancia "geography" desde la representación de una geometría en "Well-Known Binary" (WKB) o "Extended Well-Known Binary" (EWKB).
  • ST_GeomFromEWKB — Devuelve un valor especifico de ST_Geometry desde una representación " Extended Well-Known Binary" (EWKB).
  • ST_GeomFromWKB — Crea una instancia de geometría desde la representación de una geometría en "Well-Known Binary" (WKB) y un SRID opcional.
  • ST_LineFromWKB — Crea un LINESTRING desde un WKB con el SRID dado
  • ST_LinestringFromWKB — Crea una geometría desde un WKB con el SRID dado.
  • ST_PointFromWKB — Crea una geometría desde un WKB con el SRID dado.
  • ST_WKBToSQL — Devuelve un valor especifico de ST_Geometry desde una representación "Well-Known Binary" (WKB). Es un alias para ST_GeomFromWKB que no toma srid

7.8.3. Other Formats

  • ST_Box2dFromGeoHash — Devuelve un BOX2D de una cadena de GeoHash.
  • ST_GeomFromGeoHash — Devuelve una geometría de una cadena de GeoHash.
  • ST_GeomFromGML — Toma una representación GML como entrada de una geometría y extrae un objeto geométrico PostGIS
  • ST_GeomFromGeoJSON — Toma como entrada una representación geojson de una geometría y devuelve un objeto geométrico PostGIS
  • ST_GeomFromKML — Toma una representación de una geometría KML de entrada y devuelve un objeto geométrico PostGIS
  • ST_GeomFromTWKB — Crea una instancia de geometría de una representación geométrica TWKB ("Tiny Well-Known Binary").
  • ST_GMLToSQL — Devuelve un valor especifico ST_Geometry desde una representación GML. Esto es un alias de ST_GeomFromGML
  • ST_LineFromEncodedPolyline — Crea un LineString desde una polilínea codificada.
  • ST_PointFromGeoHash — Devuelve un punto de una cadena de GeoHash.
  • ST_FromFlatGeobufToTable — Creates a table based on the structure of FlatGeobuf data.
  • ST_FromFlatGeobuf — Reads FlatGeobuf data.

7.9. Geometry Output

Abstract

These functions convert geometry objects into various textual or binary formats.

7.9.1. Well-Known Text (WKT)

  • ST_AsEWKT — Return the Well-Known Text (WKT) representation of the geometry with SRID meta data.
  • ST_AsText — Return the Well-Known Text (WKT) representation of the geometry/geography without SRID metadata.

7.9.2. Well-Known Binary (WKB)

  • ST_AsBinary — Return the OGC/ISO Well-Known Binary (WKB) representation of the geometry/geography without SRID meta data.
  • ST_AsEWKB — Return the Extended Well-Known Binary (EWKB) representation of the geometry with SRID meta data.
  • ST_AsHEXEWKB — Returns a Geometry in HEXEWKB format (as text) using either little-endian (NDR) or big-endian (XDR) encoding.

7.9.3. Other Formats

  • ST_AsEncodedPolyline — Returns an Encoded Polyline from a LineString geometry.
  • ST_AsFlatGeobuf — Return a FlatGeobuf representation of a set of rows.
  • ST_AsGeobuf — Return a Geobuf representation of a set of rows.
  • ST_AsGeoJSON — Return a geometry or feature in GeoJSON format.
  • ST_AsGML — Return the geometry as a GML version 2 or 3 element.
  • ST_AsKML — Return the geometry as a KML element.
  • ST_AsLatLonText — Return the Degrees, Minutes, Seconds representation of the given point.
  • ST_AsMARC21 — Returns geometry as a MARC21/XML record with a geographic datafield (034).
  • ST_AsMVTGeom — Transforms a geometry into the coordinate space of a MVT tile.
  • ST_AsMVT — Aggregate function returning a MVT representation of a set of rows.
  • ST_AsSVG — Returns SVG path data for a geometry.
  • ST_AsTWKB — Returns the geometry as TWKB, aka "Tiny Well-Known Binary"
  • ST_AsX3D — Returns a Geometry in X3D xml node element format: ISO-IEC-19776-1.2-X3DEncodings-XML
  • ST_GeoHash — Return a GeoHash representation of the geometry.

7.10. Operadores

7.10.1. Bounding Box Operators

  • && — Returns TRUE if A's 2D bounding box intersects B's 2D bounding box.
  • &&(geometry,box2df) — Returns TRUE if a geometry's (cached) 2D bounding box intersects a 2D float precision bounding box (BOX2DF).
  • &&(box2df,geometry) — Returns TRUE if a 2D float precision bounding box (BOX2DF) intersects a geometry's (cached) 2D bounding box.
  • &&(box2df,box2df) — Returns TRUE if two 2D float precision bounding boxes (BOX2DF) intersect each other.
  • &&& — Returns TRUE if A's n-D bounding box intersects B's n-D bounding box.
  • &&&(geometry,gidx) — Returns TRUE if a geometry's (cached) n-D bounding box intersects a n-D float precision bounding box (GIDX).
  • &&&(gidx,geometry) — Returns TRUE if a n-D float precision bounding box (GIDX) intersects a geometry's (cached) n-D bounding box.
  • &&&(gidx,gidx) — Returns TRUE if two n-D float precision bounding boxes (GIDX) intersect each other.
  • &< — Returns TRUE if A's bounding box overlaps or is to the left of B's.
  • &<| — Returns TRUE if A's bounding box overlaps or is below B's.
  • &> — Returns TRUE if A' bounding box overlaps or is to the right of B's.
  • << — Returns TRUE if A's bounding box is strictly to the left of B's.
  • <<| — Returns TRUE if A's bounding box is strictly below B's.
  • = — Returns TRUE if the coordinates and coordinate order geometry/geography A are the same as the coordinates and coordinate order of geometry/geography B.
  • >> — Returns TRUE if A's bounding box is strictly to the right of B's.
  • @ — Returns TRUE if A's bounding box is contained by B's.
  • @(geometry,box2df) — Returns TRUE if a geometry's 2D bounding box is contained into a 2D float precision bounding box (BOX2DF).
  • @(box2df,geometry) — Returns TRUE if a 2D float precision bounding box (BOX2DF) is contained into a geometry's 2D bounding box.
  • @(box2df,box2df) — Returns TRUE if a 2D float precision bounding box (BOX2DF) is contained into another 2D float precision bounding box.
  • |&> — Returns TRUE if A's bounding box overlaps or is above B's.
  • |>> — Returns TRUE if A's bounding box is strictly above B's.
  • ~ — Returns TRUE if A's bounding box contains B's.
  • ~(geometry,box2df) — Returns TRUE if a geometry's 2D bonding box contains a 2D float precision bounding box (GIDX).
  • ~(box2df,geometry) — Returns TRUE if a 2D float precision bounding box (BOX2DF) contains a geometry's 2D bonding box.
  • ~(box2df,box2df) — Returns TRUE if a 2D float precision bounding box (BOX2DF) contains another 2D float precision bounding box (BOX2DF).
  • ~= — Returns TRUE if A's bounding box is the same as B's.

7.10.2. Operadores

  • <-> — Returns the 2D distance between A and B.
  • |=| — Returns the distance between A and B trajectories at their closest point of approach.
  • <#> — Returns the 2D distance between A and B bounding boxes.
  • <<->> — Returns the n-D distance between the A and B geometries or bounding boxes

7.11. Spatial Relationships

Abstract

These functions determine spatial relationships between geometries.

7.11.1. Topological Relationships

  • ST_3DIntersects — Tests if two geometries spatially intersect in 3D - only for points, linestrings, polygons, polyhedral surface (area)
  • ST_Contains — Tests if every point of B lies in A, and their interiors have a point in common
  • ST_ContainsProperly — Tests if every point of B lies in the interior of A
  • ST_CoveredBy — Tests if every point of A lies in B
  • ST_Covers — Tests if every point of B lies in A
  • ST_Crosses — Tests if two geometries have some, but not all, interior points in common
  • ST_Disjoint — Tests if two geometries have no points in common
  • ST_Equals — Tests if two geometries include the same set of points
  • ST_Intersects — Tests if two geometries intersect (they have at least one point in common)
  • ST_LineCrossingDirection — Returns a number indicating the crossing behavior of two LineStrings
  • ST_OrderingEquals — Tests if two geometries represent the same geometry and have points in the same directional order
  • ST_Overlaps — Tests if two geometries have the same dimension and intersect, but each has at least one point not in the other
  • ST_Relate — Tests if two geometries have a topological relationship matching an Intersection Matrix pattern, or computes their Intersection Matrix
  • ST_RelateMatch — Tests if a DE-9IM Intersection Matrix matches an Intersection Matrix pattern
  • ST_Touches — Tests if two geometries have at least one point in common, but their interiors do not intersect
  • ST_Within — Tests if every point of A lies in B, and their interiors have a point in common

7.11.2. Distance Relationships

  • ST_3DDWithin — Tests if two 3D geometries are within a given 3D distance
  • ST_3DDFullyWithin — Tests if two 3D geometries are entirely within a given 3D distance
  • ST_DFullyWithin — Tests if a geometry is entirely inside a distance of another
  • ST_DWithin — Tests if two geometries are within a given distance
  • ST_PointInsideCircle — Tests if a point geometry is inside a circle defined by a center and radius

7.12. Measurement Functions

Abstract

These functions compute measurements of distance, area and angles. There are also functions to compute geometry values determined by measurements.

  • 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

Abstract

These functions compute results arising from the overlay of two geometries. These are also known as point-set theoretic boolean operations. Some related functions are also provided.

  • 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. Procesamiento de geometría

Abstract

These functions compute geometric constructions, or alter geometry size or shape.

  • 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 representation of a geometry, using the Douglas-Peucker algorithm.
  • ST_SimplifyPreserveTopology — Returns a simplified and valid representation 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 representation 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

Abstract

These functions operate on sets of polygonal geometry that form "implicit coverages". To form a valid coverage polygons must not overlap, and the vertices of adjacent edges must match exactly. Coverages are fast to process, and can be operated on with window functions, which retain the coverage topology inside the window partition while altering the edges.

  • 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

Abstract

Esta función modifica la posición y la forma de las geometrías usando transformación afín.

  • 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

Abstract

These functions implement clustering algorithms for sets of geometries.

  • 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

Abstract

These functions produce or operate on bounding boxes. They can also provide and accept geometry values, by using automatic or explicit casts.

See also Section 13.7, “PostGIS 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. Referencia Lineal 

7.20. Trajectory Functions

Abstract

These functions support working with trajectories. A trajectory is a linear geometry with increasing measures (M value) on each coordinate. Spatio-temporal data can be modeled by using relative times (such as the epoch) as the measure values.

  • 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. Soporte para transacciones grandes

Abstract

Este módulo y las funciones asociadas pl/pgsql se han implementado para proporcionar soporte a bloqueos extensos que son requeridos por la especificación Web Feature Service

  • AddAuth — Agrega un testigo de autorización para usarlo en la transacción actual.
  • CheckAuth — Crea un disparador sobre una tabla para prevenir/permitir actualizaciones y borrados de filas basados en el testigo de autorización.
  • DisableLongTransactions — DisableLongTransactions
  • EnableLongTransactions — EnableLongTransactions
  • LockRow — Configura el bloqueo/autorización para una fila específica de la tabla
  • UnlockRows — Removes all locks held by an authorization token.
[Note]

Los usuarios deben usar el nivel de transacción en serie sino se rompería el mecanismo de bloqueo.

7.22. Version Functions

Abstract

Esta función informa y actualiza versiones de PostGIS.

7.23. Grand Unified Custom Variables (GUCs)

Abstract

This section lists custom PostGIS Grand Unified Custom Variables (GUC). These can be set globally, by database, by session or by transaction. Best set at global or database level.

  • 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_vsi_options — A string configuration to set options used when working with an out-db raster.

7.24. Troubleshooting Functions

Abstract

These functions are utilities for troubleshooting and repairing geometry data. They are only needed if the geometry data is corrupted in some way, which should never happen under normal circumstances.

  • PostGIS_AddBBox — Agregue el cuadro delimitador a la geometría.
  • PostGIS_DropBBox — Elimina el caché de cuadro delimitador de la geometría.
  • PostGIS_HasBBox — Devuelve TRUE si el bbox de la geometría está almacenado en caché, FALSE de lo contrario.