Spatial Functions
The following list shows available spatial functions:
Name | Description |
---|---|
DEGREES() | Convert a value in radians into degrees |
GEOHASH() | Return Geohash number |
MBRINTERSECTS() | Whether the minimum bounding rectangles of two geometries intersect |
ST_ASGEOJSON() | Return the GeoJson format representation of a geometry |
ST_ASTEXT() | Return the Well-Known Text representation of a geometry |
ST_AZIMUTH() | Return the azimuth in radians of two two geographic coordinates |
ST_AZIMUTH_GEOM() | Return the azimuth in radians of two two geometry coordinates |
ST_DISTANCE() | Return euclidean distance between two points |
ST_DISTANCE_SPHERE() | Return distance in meters between two geographic coordinates |
ST_ENDPOINT() | Return the last point of a LINESTRING |
ST_GEOHASH() | Return Geohash string |
ST_INTERSECTS() | Return 1 if two geometries intersect and 0 if they don't |
ST_MAKELINE() | Return a line from two points |
ST_MAKEPOINT() | Return a point from its coordinates |
ST_POINTFROMGEOHASH() | Return the center point of a Geohash |
ST_STARTPOINT() | Return the first point of a LINESTRING |
ST_WITHIN() | Whether one geometry is completely within another |
ST_X() | Return the x-coordinate of a point |
ST_Y() | Return the y-coordinate of a point |
GEOHASH
geohash(point, max_len)
geohash(longitude, latitude, max_len)
This function returns an INT64 number representing the Geohash with maximum max_len characters. If no max_len is specified, the default value is 12.
MBRINTERSECTS
mbrintersects(g1, g2)
This function returns 1 if the minimum bounding rectangles of g1 and g2 intersect and 0 if they don't.
ST_ASGEOJSON
st_asgeojson(g1 [, precision])
Returns the GeoJson format representation of a geometry.
ST_ASTEXT
st_astext(g1 [, precision])
Returns Return the Well-Known Text representation of a geometry.
ST_DISTANCE_SPHERE
st_distance_sphere(point1, point2)
st_distance_sphere(lon1, lat1, lon2, lat2)
Returns the linear distance in meters between two geographic coordinates.
ST_GEOHASH
st_geohash(longitude, latitude [, max_len])
Returns the Geohash string representing the location with maximum max_len characters. The maximum value for max_len is 12. If max_len is not specified, the default value 12 is used.
st_geohash(geohash_number)
Returns the Geohash string of geohash_number.
ST_INTERSECTS
st_intersects(g1, g2)
This function returns 1 if g1 and g2 intersect and 0 if they don't.
ST_MAKELINE
st_makeline(p1, p2)
Constructs a line from two points.
ST_MAKEPOINT
st_makepoint(x, y)
Constructs a point from its coordinates.
ST_POINTFROMGEOHASH
st_pointfromgeohash(gh)
Returns the center point from a Geohash gh, which can be a Geohash string or Geohash number.
ST_WITHIN
st_within(g1, g2)
Returns 1 or 0 to indicate whether g1 is completely within g2.