All Products
Search
Document Center

ApsaraDB RDS:Operators

Last Updated:Aug 12, 2025

This topic describes the operators supported by GeomGrid SQL, including their syntax, parameters, and examples.

Supported operators

Operator

Description

@>

Queries whether the spatial extent of a grid object contains a geometry object.

<@

Queries whether the spatial extent of a grid object is contained by a geometry object.

&&&

Queries whether the spatial extent of a geographic grid object intersects with a geometry object.

@@>

Queries whether the spatial extent of a geographic grid object contains a geometry object.

<@@

Queries whether the spatial extent of a geographic grid object is contained by a geometry object.

&&

Checks for spatial intersection between the bounding boxes of two GeomGrid/Geometry objects or two H3Grid/Geometry objects.

~

Checks for spatial containment between the bounding boxes of two GeomGrid/Geometry objects or two H3Grid/Geometry objects.

@

Checks for spatial containment between the bounding boxes of two GeomGrid/Geometry objects or two H3Grid/Geometry objects.

The syntax, parameters, and examples for each operator are as follows:

@>

Queries whether the spatial extent of a grid object contains a geometry object.

Syntax

boolean @>(geomgrid grid, geometry geom);
boolean @>(geometry geom, geomgrid grid);
boolean @>(geomgrid grid1, geomgrid grid2);

Parameters

Parameter

Description

grid

The grid object.

geom

The geometry object.

Notes

The geometry object must use the CGC2000 spatial reference system (SRID=4490).

Examples

  • Example 1:

    SELECT ST_gridfromtext('G001331032213300013') @>
           ST_geomfromtext('POINT(116.31522216796875 39.910277777777778)',4490) AS t;

    Return value:

     t
    ---------------
     f
  • Example 2:

    SELECT ST_gridfromtext('G00133103221330') @>
           ST_gridfromtext('G001331032213300013') AS t;

    Return value:

     t 
    -------------
     t

<@

Queries whether the spatial extent of a grid object is contained by a geometry object.

Syntax

boolean <@(geomgrid grid, geometry geom);
boolean <@(geometry geom, geomgrid grid);
boolean <@(geomgrid grid1, geomgrid grid2);

Parameters

Parameter

Description

grid

The grid object.

geom

The geometry object.

Notes

The geometry object must use the CGC2000 spatial reference system (SRID=4490).

Examples

  • Example 1:

    SELECT ST_geomfromtext('POINT(116.31522216796875 39.910277777777778)',4490) <@
           ST_gridfromtext('G001331032213300013') AS t;

    Return value:

     t 
    ---------------
     f
  • Example 2:

    SELECT ST_gridfromtext('G001331032213300013') <@
            ST_gridfromtext('G001331032213300') AS t;

    Return value:

     t 
    -------------
     t

&&&

Queries whether the spatial extent of a geographic grid object intersects with a geometry object.

Syntax

bool &&&(geometry geom3d, geomgrid gridcode);
bool &&&(geomgrid gridcode, geometry geom3d);
bool &&&(meshgeom geom3d, geomgrid gridcode);
bool &&&(geomgrid gridcode, meshgeom geom3d);
bool &&&(sfmesh geom3d, geomgrid gridcode);
bool &&&(geomgrid gridcode, sfmesh geom3d);
bool &&&(vomesh geom3d, geomgrid gridcode);
bool &&&(geomgrid gridcode, vomesh geom3d);
bool &&&(geomgrid gridcode1, geomgrid gridcode2);

Parameters

Parameter

Description

gridcode/gridcode1/gridcode2

The geographic grid object.

geom3d

The 3D geometry object.

Notes

The geometry object must use the CGC2000 spatial reference system (SRID=4490).

Examples

  • Example 1:

    SELECT ST_GridFromText('GZ00262064446046072072') &&&
    'srid=4490;POINT(116.31522216796875 39.910277777777778 1001.8)'::geometry;

    Return value:

     st_3dintersects 
    -----------------
     f
  • Example 2:

    SELECT ST_GridFromText('GZ00262064') &&& ST_GridFromText('GZ00262063');

    Return value:

     st_3dintersects 
    -----------------
     t

@@>

Queries whether the spatial extent of a geographic grid object contains a geometry object.

Syntax

bool @@>(geometry geom3d, geomgrid gridcode);
bool @@>(geomgrid gridcode, geometry geom3d);
bool @@>(meshgeom geom3d, geomgrid gridcode);
bool @@>(geomgrid gridcode, meshgeom geom3d);
bool @@>(sfmesh geom3d, geomgrid gridcode);
bool @@>(geomgrid gridcode, sfmesh geom3d);
bool @@>(vomesh geom3d, geomgrid gridcode);
bool @@>(geomgrid gridcode, vomesh geom3d);
bool @@>(geomgrid gridcode1, geomgrid gridcode2);

Parameters

Parameter

Description

gridcode/gridcode1/gridcode2

The geographic grid object.

geom3d

The 3D geometry object.

Notes

The geometry object must use the CGC2000 spatial reference system (SRID=4490).

Examples

  • Example 1:

    SELECT ST_GridFromText('GZ00262064446046072072') @@> 
    'srid=4490;POINT(116.31522216796875 39.910277777777778 1001.8)'::geometry;

    Return value:

     st_3dcontains 
    -----------------
     t
  • Example 2:

    SELECT ST_GridFromText('GZ00262064') @@> ST_GridFromText('GZ002620643');

    Return value:

     st_3dcontains 
    -----------------
     t

<@@

Queries whether the spatial extent of a geographic grid object is contained by a geometry object.

Syntax

bool <@@(geometry geom3d, geomgrid gridcode);
bool <@@(geomgrid gridcode, geometry geom3d);
bool <@@(meshgeom geom3d, geomgrid gridcode);
bool <@@(geomgrid gridcode, meshgeom geom3d);
bool <@@(sfmesh geom3d, geomgrid gridcode);
bool <@@(geomgrid gridcode, sfmesh geom3d);
bool <@@(vomesh geom3d, geomgrid gridcode);
bool <@@(geomgrid gridcode, vomesh geom3d);
bool <@@(geomgrid gridcode1, geomgrid gridcode2);

Parameters

Parameter

Description

gridcode/gridcode1/gridcode2

The geographic grid object.

geom3d

The 3D geometry object.

Notes

The geometry object must use the CGC2000 spatial reference system (SRID=4490).

Example

SELECT ST_GridFromText('GZ0026206435') <@@ ST_GridFromText('GZ002620643');

Return value:

 st_3dwithin 
-----------------
 t

&&

Checks for spatial intersection between the bounding boxes of two GeomGrid/Geometry objects or two H3Grid/Geometry objects. The GeomGrid or H3Grid object is converted to a Geometry object before the bounding box relationship is checked.

Syntax

bool &&(GeomGrid A, GeomGrid B);
bool &&(GeomGrid A, Geometry B);
bool &&(Geometry A, GeomGrid B);
bool &&(H3Grid A, H3Grid B);
bool &&(H3Grid A, Geometry B);
bool &&(Geometry A, H3Grid B);

Return value

Returns true if their bounding boxes intersect. Otherwise, it returns false.

Parameters

Parameter

Description

A

A GeomGrid, H3Grid, or Geometry object.

B

A GeomGrid, H3Grid, or Geometry object.

Description

  • Checks for spatial intersection between the bounding boxes of two GeomGrid/Geometry objects or two H3Grid/Geometry objects. This operator returns true if they intersect and false otherwise.

  • A GeomGrid or H3Grid object is converted to a Geometry object before the bounding box relationship is checked.

  • By default, a GeomGrid object is converted to a Geometry object that uses the CGC2000 coordinate system (SRID=4490).

  • By default, an H3Grid object is converted to a Geometry object that uses the WGS 84 coordinate system (SRID=4326).

Examples

  • Example 1:

    --&& (GeomGrid, GeomGrid)
    SELECT COUNT(*) from geomgrid_gist_test WHERE 'G00'::GeomGrid && code;

    Return value:

    
    -------
         5
  • Example 2:

    --&& (GeomGrid, Geometry)
    SELECT COUNT(*) from geomgrid_gist_test WHERE code && 'SRID=4490;POLYGON((80 20,90 20,90 25,80 25,80 20))'::Geometry;

    Return value:

    
    -------
         5
  • Example 3:

    --&& (H3Grid, H3Grid)
    SELECT COUNT(*) from h3grid_gist_test where code && ST_H3FromLatLng(-17.5, -65.0, 1);

    Returns:

    
    -------
         1
  • Example 4:

    --&& (Geometry, H3Grid)
    SELECT COUNT(*) from h3grid_gist_test WHERE 'SRID=4490;POLYGON((-70 -20,-60 -20,-60 -10,-70 -10,-70 -20))'::Geometry && code;

    Return value:

    
    -------
         1

~

Checks for spatial containment between the bounding boxes of two GeomGrid/Geometry objects or two H3Grid/Geometry objects. The GeomGrid or H3Grid object is converted to a Geometry object before the bounding box relationship is checked.

Syntax

bool ~(GeomGrid A, GeomGrid B);
bool ~(GeomGrid A, Geometry B);
bool ~(Geometry A, GeomGrid B);
bool ~(H3Grid A, H3Grid B);
bool ~(H3Grid A, Geometry B);
bool ~(Geometry A, H3Grid B);

Return value

Returns true if the bounding box of object A contains the bounding box of object B. Otherwise, it returns false.

Parameters

Parameter

Description

A

A GeomGrid, H3Grid, or Geometry object.

B

A GeomGrid, H3Grid, or Geometry object.

Description

  • Checks for spatial containment between the bounding boxes of two GeomGrid/Geometry objects or two H3Grid/Geometry objects. This operator returns true if the bounding box of object A contains the bounding box of object B, and false otherwise.

  • A GeomGrid or H3Grid object is converted to a Geometry object before the bounding box relationship is checked.

  • By default, a GeomGrid object is converted to a Geometry object that uses the CGC2000 coordinate system (SRID=4490).

  • By default, an H3Grid object is converted to a Geometry object that uses the WGS 84 coordinate system (SRID=4326).

Examples

  • Example 1:

    --~ (GeomGrid, GeomGrid)
    SELECT COUNT(*) from geomgrid_gist_test WHERE 'G00'::GeomGrid ~ code;

    Return value:

    
    -------
         5
  • Example 2:

    --~ (Geometry, GeomGrid)
    SELECT COUNT(*) from geomgrid_gist_test WHERE 'SRID=4490;POLYGON((88 24,88.8 24,88.8 24.5,88 24.5,88 24))'::Geometry ~ code;

    Return value:

    
    -------
         2
  • Example 3:

    --~ (H3Grid, H3Grid)
    SELECT COUNT(*) from h3grid_gist_test where code ~ ST_H3FromLatLng(-17.5, -65.0, 1);

    Return value:

    
    -------
         0
  • Example 4:

    --~ (Geometry, H3Grid)
    SELECT COUNT(*) from h3grid_gist_test WHERE 'SRID=4326;POLYGON((0 30,5 30,5 38,0 38,0 30))'::Geometry ~ code;

    Return value:

    
    -------
         1

@

Checks for spatial containment between the bounding boxes of two GeomGrid/Geometry objects or two H3Grid/Geometry objects. The GeomGrid or H3Grid object is converted to a Geometry object before the bounding box relationship is checked.

Syntax

bool @(GeomGrid A, GeomGrid B);
bool @(GeomGrid A, Geometry B);
bool @(Geometry A, GeomGrid B);
bool @(H3Grid A, H3Grid B);
bool @(H3Grid A, Geometry B);
bool @(Geometry A, H3Grid B);

Return value

Returns true if the bounding box of object A is contained by the bounding box of object B. Otherwise, it returns false.

Parameters

Parameter

Description

A

A GeomGrid, H3Grid, or Geometry object.

B

A GeomGrid, H3Grid, or Geometry object.

Description

  • Checks for spatial containment between the bounding boxes of two GeomGrid/Geometry objects or two H3Grid/Geometry objects. This operator returns true if the bounding box of object A is contained by the bounding box of object B, and false otherwise.

  • A GeomGrid or H3Grid object is converted to a Geometry object before the bounding box relationship is checked.

  • By default, a GeomGrid object is converted to a Geometry object that uses the CGC2000 coordinate system (SRID=4490).

  • By default, an H3Grid object is converted to a Geometry object that uses the WGS 84 coordinate system (SRID=4326).

Examples

  • Example 1:

    --@ (GeomGrid, GeomGrid)
    SELECT COUNT(*) from geomgrid_gist_test WHERE code @ 'G00'::GeomGrid;

    Return value:

    
    -------
         5
  • Example 2:

    --@ (GeomGrid, Geometry)
    SELECT COUNT(*) from geomgrid_gist_test WHERE code @ 'SRID=4490;POLYGON((88 24,88.8 24,88.8 24.5,88 24.5,88 24))'::Geometry;

    Return value:

    
    -------
         2
  • Example 3:

    --@ (H3Grid, H3Grid)
    SELECT COUNT(*) from h3grid_gist_test where code @ ST_H3FromLatLng(-17.5, -65.0, 1);

    Return value:

    
    -------
         1
  • Example 4:

    --@ (H3Grid, Geometry)
    SELECT COUNT(*) from h3grid_gist_test WHERE code @ 'SRID=4490;POLYGON((0 30,5 30,5 38,0 38,0 30))'::Geometry;

    Return value:

    
    -------
         1