Movatterモバイル変換


[0]ホーム

URL:


Loading
  1. Elastic Docs/
  2. Reference/
  3. Query languages/
  4. SQL/
  5. Functions and operators

Geo functions

Warning

This functionality is in beta and is subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Beta features are not subject to the support SLA of official GA features.

The geo functions work with geometries stored ingeo_point,geo_shape andshape fields, or returned by other geo functions.

geo_point,geo_shape andshape and types are represented in SQL as geometry and can be used interchangeably with the following exceptions:

  • geo_shape andshape fields don’t have doc values, therefore these fields cannot be used for filtering, grouping or sorting.
  • geo_points fields are indexed and have doc values by default, however only latitude and longitude are stored and indexed with some loss of precision from the original values (4.190951585769653E-8 for the latitude and 8.381903171539307E-8 for longitude). The altitude component is accepted but not stored in doc values nor indexed. Therefore callingST_Z function in the filtering, grouping or sorting will returnnull.
ST_AsWKT(    geometry)

Input:

  1. geometry. Ifnull, the function returnsnull.

Output: string

Description: Returns the WKT representation of thegeometry.

SELECT city, ST_AsWKT(location) location FROM "geo" WHERE city = 'Amsterdam';     city:s    |     location:sAmsterdam      |POINT (4.850312 52.347557)
ST_WKTToSQL(    string)

Input:

  1. string WKT representation of geometry. Ifnull, the function returnsnull.

Output: geometry

Description: Returns the geometry from WKT representation.

SELECT CAST(ST_WKTToSQL('POINT (10 20)') AS STRING) location;   location:sPOINT (10.0 20.0)
ST_GeometryType(    geometry)

Input:

  1. geometry. Ifnull, the function returnsnull.

Output: string

Description: Returns the type of thegeometry such as POINT, MULTIPOINT, LINESTRING, MULTILINESTRING, POLYGON, MULTIPOLYGON, GEOMETRYCOLLECTION, ENVELOPE or CIRCLE.

SELECT ST_GeometryType(ST_WKTToSQL('POINT (10 20)')) type;      type:sPOINT
ST_X(    geometry)

Input:

  1. geometry. Ifnull, the function returnsnull.

Output: double

Description: Returns the longitude of the first point in the geometry.

SELECT ST_X(ST_WKTToSQL('POINT (10 20)')) x;      x:d10.0
ST_Y(    geometry)

Input:

  1. geometry. Ifnull, the function returnsnull.

Output: double

Description: Returns the latitude of the first point in the geometry.

SELECT ST_Y(ST_WKTToSQL('POINT (10 20)')) y;      y:d20.0
ST_Z(    geometry)

Input:

  1. geometry. Ifnull, the function returnsnull.

Output: double

Description: Returns the altitude of the first point in the geometry.

SELECT ST_Z(ST_WKTToSQL('POINT (10 20 30)')) z;      z:d30.0
ST_Distance(    geometry,    geometry)

Input:

  1. source geometry. Ifnull, the function returnsnull.
  2. target geometry. Ifnull, the function returnsnull.

Output: Double

Description: Returns the distance between geometries in meters. Both geometries have to be points.

SELECT ST_Distance(ST_WKTToSQL('POINT (10 20)'), ST_WKTToSQL('POINT (20 30)')) distance;   distance:d1499101.2889383635

[8]ページ先頭

©2009-2026 Movatter.jp