ST_Envelope
Definición
ST_Envelope devuelve el cuadro de delimitación mínimo de un objeto de geometría como un polígono.
Esta función cumple con la especificación de entidades simples del Consorcio Geoespacial abierto (OGC) que indica que ST_Envelope devuelve un polígono. Para trabajar con casos especiales de geometrías de punto o líneas horizontales o verticales, la función ST_Envelope devuelve un polígono alrededor de estas formas, que es una pequeña tolerancia de sobre que se calcula en base al factor de escala XY para el sistema de referencia espacial de la geometría. Esta tolerancia se resta de las coordenadas x e y mín. y se suma a las coordenadas x e y máx. para devolver el polígono que rodea a estas formas.
Sintaxis
Oracle y PostgreSQL
sde.st_envelope (geometry1 sde.st_geometry)
SQLite
st_envelope (geometry1 geometryblob)
Tipo de devolución
Oracle y PostgreSQL
ST_Geometry
SQLite
Geometryblob
Ejemplo
La columna geotype de la tabla envelope_test almacena el nombre de la subclase de geometría almacenada en la columna g1. Las declaraciones INSERT insertan cada subclase de geometría en la tabla envelope_test.
A continuación, la función ST_Envelope se ejecuta para devolver el sobre del polígono que rodea a cada geometría.
Oracle
--Create table and insert values.
CREATE TABLE envelope_test (
geotype varchar(20),
g1 sde.st_geometry
);
INSERT INTO ENVELOPE_TEST VALUES (
'Point',
sde.st_geometry ('point (-1509734.232 -36684.757)', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Linestring',
sde.st_geometry ('linestring (-1511144.181 -37680.015, -1509734.232 -38841.149, -1508656.036 -39753.469)', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Polygon',
sde.st_geometry ('polygon ((-1506333.768 -36435.943, -1504343.252 -36767.695, -1502684.489 -35357.747, -1506333.768 -36435.943))', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Multipoint',
sde.st_geometry ('multipoint (-1493229.539 -40665.789, -1494141.859 -40831.665, -1495800.622 -42739.242)', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Multilinestring',
sde.st_geometry ('multilinestring ((-1504757.943 -33201.355, -1507411.964 -35606.561), (-1502518.613 -38094.706, -1499781.653 -37099.448, -1498952.272 -34694.241))', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Multipolygon',
sde.st_geometry ('multipolygon (((-1492068.405 -47300.841, -1492814.848 -45725.016, -1493975.983 -46471.459,
-1493478.354 -47798.47, -1492068.405 -47300.841), (-1497874.076 -48047.284, -1498537.581 -50618.367, -1497210.571 -50037.8,
-1497874.076 -48047.284)))', 102004)
);
--Return the polygon envelope around each geometry in well-known text.
SELECT geotype geometry_type,
sde.st_astext (sde.st_envelope (g1)) envelope
FROM ENVELOPE_TEST;
GEOMETRY_TYPE ENVELOPE
Point |POLYGON (( -1509734.23220000 -36684.75720000, -1509734.23180000 -36684.75720000,
-1509734.23180000 -36684.75680000, -1509734.23220000 -36684.75680000, -1509734.23220000 -36684.75720000))
Linestring |POLYGON (( -1511144.18100000 -39753.46900000, -1508656.03600000 -39753.46900000,
-1508656.03600000 -37680.01500000, -1511144.18100000 -37680.01500000, -1511144.18100000 -39753.46900000))
Polygon |POLYGON (( -1506333.76800000 -36767.69500000, -1502684.48900000 -36767.69500000,
-1502684.48900000 -35357.74700000, -1506333.76800000 -35357.74700000, -1506333.76800000 -36767.69500000))
Multipoint |POLYGON (( -1495800.62200000 -42739.24200000, -1493229.53900000 -42739.24200000,
-1493229.53900000 -40665.78900000, -1495800.62200000 -40665.78900000, -1495800.62200000 -42739.24200000))
Multilinestring |POLYGON (( -1507411.96400000 -38094.70600000, -1498952.27200000 -38094.70600000,
-1498952.27200000 -33201.35500000, -1507411.96400000 -33201.35500000, -1507411.96400000 -38094.70600000))
Multipolygon |POLYGON (( -1498537.58100000 -50618.36700000, -1492068.40500000 -50618.36700000,
-1492068.40500000 -45725.01600000, -1498537.58100000 -45725.01600000, -1498537.58100000 -50618.36700000))
PostgreSQL
--Create table and insert values.
CREATE TABLE envelope_test (
geotype varchar(20),
g1 sde.st_geometry
);
INSERT INTO ENVELOPE_TEST VALUES (
'Point',
sde.st_geometry ('point (-1509734.232 -36684.757)', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Linestring',
sde.st_geometry ('linestring (-1511144.181 -37680.015, -1509734.232 -38841.149, -1508656.036 -39753.469)', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Polygon',
sde.st_geometry ('polygon ((-1506333.768 -36435.943, -1504343.252 -36767.695, -1502684.489 -35357.747, -1506333.768 -36435.943))', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Multipoint',
sde.st_geometry ('multipoint (-1493229.539 -40665.789, -1494141.859 -40831.665, -1495800.622 -42739.242)', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Multilinestring',
sde.st_geometry ('multilinestring ((-1504757.943 -33201.355, -1507411.964 -35606.561), (-1502518.613 -38094.706, -1499781.653 -37099.448, -1498952.272 -34694.241))', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Multipolygon',
sde.st_geometry ('multipolygon (((-1492068.405 -47300.841, -1492814.848 -45725.016, -1493975.983 -46471.459,
-1493478.354 -47798.47, -1492068.405 -47300.841), (-1497874.076 -48047.284, -1498537.581 -50618.367, -1497210.571 -50037.8,
-1497874.076 -48047.284)))', 102004)
);
--Return the polygon envelope around each geometry in well-known text.
SELECT geotype AS geometry_type,
sde.st_astext (sde.st_envelope (g1)) AS Envelope
FROM envelope_test;
geometry_type envelope
"Point" |"POLYGON (( -1509734.23220000 -36684.75720000, -1509734.23180000 -36684.75720000,
-1509734.23180000 -36684.75680000, -1509734.23220000 -36684.75680000, -1509734.23220000 -36684.75720000))"
"Linestring" |"POLYGON (( -1511144.18100000 -39753.46900000, -1508656.03600000 -39753.46900000,
-1508656.03600000 -37680.01500000, -1511144.18100000 -37680.01500000, -1511144.18100000 -39753.46900000))"
"Polygon" |"POLYGON (( -1506333.76800000 -36767.69500000, -1502684.48900000 -36767.69500000,
-1502684.48900000 -35357.74700000, -1506333.76800000 -35357.74700000, -1506333.76800000 -36767.69500000))"
"Multipoint" |"POLYGON (( -1495800.62200000 -42739.24200000, -1493229.53900000 -42739.24200000,
-1493229.53900000 -40665.78900000, -1495800.62200000 -40665.78900000, -1495800.62200000 -42739.24200000))"
"Multilinestring" |"POLYGON (( -1507411.96400000 -38094.70600000, -1498952.27200000 -38094.70600000,
-1498952.27200000 -33201.35500000, -1507411.96400000 -33201.35500000, -1507411.96400000 -38094.70600000))"
"Multipolygon" |"POLYGON (( -1498537.58100000 -50618.36700000, -1492068.40500000 -50618.36700000,
-1492068.40500000 -45725.01600000, -1498537.58100000 -45725.01600000, -1498537.58100000 -50618.36700000))"
SQLite
--Create table and insert values.
CREATE TABLE envelope_test (
geotype varchar(20)
);
SELECT AddGeometryColumn (
NULL,
'envelope_test',
'g1',
4326,
'geometry',
'xy',
'null'
);
INSERT INTO ENVELOPE_TEST VALUES (
'Point',
st_geometry ('point (-1509734.232 -36684.757)', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Linestring',
st_geometry ('linestring (-1511144.181 -37680.015, -1509734.232 -38841.149, -1508656.036 -39753.469)', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Polygon',
st_geometry ('polygon ((-1506333.768 -36435.943, -1504343.252 -36767.695, -1502684.489 -35357.747, -1506333.768 -36435.943))', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Multipoint',
st_geometry ('multipoint (-1493229.539 -40665.789, -1494141.859 -40831.665, -1495800.622 -42739.242)', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Multilinestring',
st_geometry ('multilinestring ((-1504757.943 -33201.355, -1507411.964 -35606.561), (-1502518.613 -38094.706, -1499781.653 -37099.448, -1498952.272 -34694.241))', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Multipolygon',
st_geometry ('multipolygon (((-1492068.405 -47300.841, -1492814.848 -45725.016, -1493975.983 -46471.459,
-1493478.354 -47798.47, -1492068.405 -47300.841), (-1497874.076 -48047.284, -1498537.581 -50618.367, -1497210.571 -50037.8,
-1497874.076 -48047.284)))', 102004)
);
--Return the polygon envelope around each geometry in well-known text.
SELECT geotype AS geometry_type,
st_astext (st_envelope (g1)) AS "Envelope"
FROM envelope_test;
geometry_type Envelope
Point POLYGON (( -1509734.23220000 -36684.75720000, -1509734.23180000 -36684.75720000,
-1509734.23180000 -36684.75680000, -1509734.23220000 -36684.75680000, -1509734.23220000 -36684.75720000))
Linestring POLYGON (( -1511144.18100000 -39753.46900000, -1508656.03600000 -39753.46900000,
-1508656.03600000 -37680.01500000, -1511144.18100000 -37680.01500000, -1511144.18100000 -39753.46900000))
Polygon POLYGON (( -1506333.76800000 -36767.69500000, -1502684.48900000 -36767.69500000,
-1502684.48900000 -35357.74700000, -1506333.76800000 -35357.74700000, -1506333.76800000 -36767.69500000))
Multipoint POLYGON (( -1495800.62200000 -42739.24200000, -1493229.53900000 -42739.24200000,
-1493229.53900000 -40665.78900000, -1495800.62200000 -40665.78900000, -1495800.62200000 -42739.24200000))
Multilinestring POLYGON (( -1507411.96400000 -38094.70600000, -1498952.27200000 -38094.70600000,
-1498952.27200000 -33201.35500000, -1507411.96400000 -33201.35500000, -1507411.96400000 -38094.70600000))
Multipolygon POLYGON (( -1498537.58100000 -50618.36700000, -1492068.40500000 -50618.36700000,
-1492068.40500000 -45725.01600000, -1498537.58100000 -45725.01600000, -1498537.58100000 -50618.36700000))