This topic describes the ST_ClipByBox2D function. This function clips an input geometry object by using a 2D box in a fast way.

Syntax

geometry  ST_ClipByBox2D(geometry  geom , box2d  box);

Parameters

Parameter Description
geom The geometry object that you want to specify.
box The 2D box that is used for clipping.

Description

  • This function may return an invalid geometry object. This function may introduce a polygon object with self-intersections.
  • If the input geometry object has an invalid topology, no error is reported.

Examples

Results returned by using the default parameter settings:
SELECT ST_AsText(ST_ClipByBox2D('LINESTRING(0 1,2 1)'::geometry,ST_MakeEnvelope(0,0,1,2)));
      st_astext
---------------------
 LINESTRING(0 1,1 1)
(1 row)
                
1