ArcGIS Server Banner

ST_ConvexHull

ST_ConvexHull

Release 9.3 E-mail This TopicPrintable VersionGive Us feedback
Note: This topic was updated for 9.3.1.

Definition

ST_ConvexHull returns the convex hull of a geometry object.

Syntax

Oracle

sde.st_convexhull (g1 sde.st_geometry)

PostgreSQL

st_convexhull (g1 st_geometry)

Return type

ST_Geometry

Example

The example creates the sample_geometries table that has three columns: id, spatial_type, and geometry. The column spatial_type, a varchar(18), stores the name of the geometry subclass that is stored in the geometry column.

Oracle

CREATE TABLE sample_geometries (id integer, spatial_type varchar(18), geometry sde.st_geometry);

INSERT INTO sample_geometries (id, spatial_type, geometry) VALUES (
1,
'ST_LineString',
sde.st_linestring ('linestring (20 20, 30 30, 20 40, 30 50)', 0)
);

INSERT INTO sample_geometries (id, spatial_type, geometry) VALUES (
2,
'ST_Polygon',
sde.st_polygon ('polygon ((30 30, 25 35, 15 50, 35 80, 40 85, 80 90,70 75, 65 70, 55 50, 75 40, 60 30, 30 30))', 0)
);

INSERT INTO sample_geometries (id, spatial_type, geometry) VALUES (
3, 
'ST_MultiPoint',
sde.st_multipoint ('multipoint (20 20, 30 30, 20 40, 30 50)', 0)
);

PostgreSQL

CREATE TABLE sample_geometries (id integer, spatial_type varchar(18), geometry st_geometry);

INSERT INTO sample_geometries (id, spatial_type, geometry) VALUES (
1,
'ST_LineString',
st_linestring ('linestring (20 20, 30 30, 20 40, 30 50)', 0)
);

INSERT INTO sample_geometries (id, spatial_type, geometry) VALUES (
2,
'ST_Polygon',
st_polygon ('polygon ((30 30, 25 35, 15 50, 35 80, 40 85, 80 90,70 75, 65 70, 55 50, 75 40, 60 30, 30 30))', 0)
);

INSERT INTO sample_geometries (id, spatial_type, geometry) VALUES (
3, 
'ST_MultiPoint',
st_multipoint ('multipoint (20 20, 30 30, 20 40, 30 50)', 0)
);

The SELECT statement lists the subclass name stored in the spatial_type column and the convex hull of the geometry.

Oracle

SELECT id, spatial_type, sde.st_astext (sde.st_convexhull (geometry)) CONVEXHULL
FROM  sample_geometries;

ID    SPATIAL_TYPE       CONVEXHULL

 1    ST_LineString      POLYGON ((20.00000000 40.00000000, 
                           20.00000000 20.00000000, 30.00000000 
                           30.00000000, 30.00000000 50.00000000, 
                           20.00000000 40.00000000)) 

 2    ST_Polygon         POLYGON ((15.00000000 50.00000000, 
                           25.00000000 35.00000000, 30.00000000 
                           30.00000000, 60.00000000 30.00000000,
                           75.00000000 40.00000000, 80.00000000 
                           90.00000000, 40.00000000 85.00000000,
                           35.00000000 80.00000000, 15.00000000 
                           50.00000000))

 3    ST_MultiPoint      POLYGON ((20.00000000 40.00000000, 
                           20.00000000 20.00000000, 30.00000000 
                           30.00000000, 30.00000000 50.00000000, 
                           20.00000000 40.00000000)) 

PostgreSQL

SELECT id, spatial_type, st_astext (st_convexhull (geometry)) AS CONVEXHULL
FROM sample_geometries;

id    spatial_type       convexhull

 1    ST_LineString      POLYGON ((20 40, 20 20, 30 30, 30 50, 
                           20 40)) 

  2    ST_Polygon         POLYGON ((15 50, 25 35, 30 30, 60 30,
                           75 40, 80 90, 40 85, 35 80, 15 50))

 3    ST_MultiPoint      POLYGON ((20 40, 20 20, 30 30, 30  50, 
                           20 40)) 

See Also

  • An overview of SQL functions used with ST_Geometry types
  • Spatial operations