ST_Distance_Sphere()

Returns the great-circle distance in meters between POINT or MULTIPOINT geometries.

Syntax

ST_Distance_Sphere(geom1, geom2)

Aliases: none.

Arguments

geom1 and geom2 are both GEOMETRY or both GEOMETRY32 values.

Return Value

Returns FLOAT64 for GEOMETRY inputs and FLOAT32 for GEOMETRY32 inputs.

Usage Notes

  • Both operands must be POINT or MULTIPOINT, have matching SRIDs, and use longitude in [-180, 180] and latitude in [-90, 90].

  • The sphere kernel interprets X/Y as degrees regardless of SRID.

Examples

DROP DATABASE IF EXISTS geo_distance_sphere_demo;
CREATE DATABASE geo_distance_sphere_demo;
USE geo_distance_sphere_demo;

SELECT ST_Distance_Sphere(ST_GeomFromText('POINT(0 0)'), ST_GeomFromText('POINT(1 0)')) AS one_degree_meters;

DROP DATABASE geo_distance_sphere_demo;

See Also

ST_Distance(), ST_Length().