Spatial Relationships
st_area
Double st_area(Geometry g)
If Geometry g is areal, this function returns the area of its surface in square units of the coordinate reference system (for example, degrees^2 for EPSG:4326). This function returns 0.0 for non-areal geometries (for example, Points and non-closed LineStrings).
Example:
st_centroid
Point st_centroid(Geometry g)
This function returns the geometric center of a geometry.
Example:
st_closestPoint
Point st_closestPoint(Geometry a, Geometry b)
This function returns the Point on a that is closest to b. This is the first point of the shortest line.
Example:
st_contains
Boolean st_contains(Geometry a, Geometry b)
This function returns true if and only if no points of b lie in the exterior of a, and at least one point of the interior of b lies in the interior of a.
Example:
st_covers
Boolean st_covers(Geometry a, Geometry b)
This function returns true if no point in Geometry b is outside Geometry a.
Example:
st_crosses
Boolean st_crosses(Geometry a, Geometry b)
This function returns true if the supplied geometries have some, but not all, interior points in common.
Example:
st_disjoint
Boolean st_disjoint(Geometry a, Geometry b)
This function returns true if the geometries do not spatially intersect, for example, they do not share any space together. This function is equivalent to NOT st_intersects(a, b).
Example:
st_distance
Double st_distance(Geometry a, Geometry b)
This function returns the 2D Cartesian distance between the two geometries in units of the coordinate reference system (for example, degrees for EPSG:4236).
Example:
st_distanceSphere
Double st_distanceSphere(Geometry a, Geometry b)
This function approximates the minimum distance between two longitude/latitude geometries assuming a spherical earth.
Example:
st_distanceSpheroid
Double st_distanceSpheroid(Geometry a, Geometry b)
This function returns the minimum distance between two longitude/latitude geometries assuming the WGS84 spheroid.
Example:
st_equals
Boolean st_equals(Geometry a, Geometry b)
This function returns true if the given Geometries represent the same logical Geometry. Directionality is ignored.
Example:
st_intersects
Boolean st_intersects(Geometry a, Geometry b)
This function returns true if the geometries spatially intersect in 2D (for example, share any portion of space). This function is equivalent to NOT st_disjoint(a, b).
Example:
st_length
Double st_length(Geometry geom)
This function returns the 2D path length of linear geometries, or perimeter of areal geometries, in units of the coordinate reference system (for example, degrees for EPSG:4236). It returns 0.0 for other geometry types (for example, Point).
Example:
st_lengthSphere
Double st_lengthSphere(LineString line)
This function approximates the 2D path length of a LineString geometry using a spherical earth model. The returned length is in units of meters. The approximation is within 0.3% of st_lengthSpheroid and is computationally more efficient.
Example:
- Query command:
select st_lengthSphere(st_castToLineString(st_geomFromWKT(location))) from geotbl where id='5'
- The query result is as follows:
1.0013773137296816E7
st_lengthSpheroid
Double st_lengthSpheroid(LineString line)
This function calculates the 2D path length of a LineString geometry defined with longitude/latitude coordinates on the WGS84 spheroid. The returned length is in units of meters.
Example:
st_overlaps
Boolean st_overlaps(Geometry a, Geometry b)
This function returns true if the geometries have some but not all points in common, are of the same dimension, and the intersection of the interiors of the two geometries has the same dimension as the geometries themselves.
Example:
st_relate
String st_relate(Geometry a, Geometry b)
This function returns the DE-9IM 3x3 interaction matrix pattern describing the dimensionality of the intersections between the interior, boundary and exterior of the two geometries.
Example:
st_relateBool
Boolean st_relateBool(Geometry a, Geometry b, String mask)
This function returns true if the DE-9IM interaction matrix mask matches the interaction matrix pattern obtained from st_relate(a, b).
Example:
st_touches
Boolean st_touches(Geometry a, Geometry b)
This function returns true if the geometries have at least one point in common, but their interiors do not intersect.
Example:
st_within
Boolean st_within(Geometry a, Geometry b)
This function returns true if geometry a is completely inside geometry b.
Example:
Last Article: Geometry Outputs
Next Article: Geometry Processing
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.