To use these functions, you must understand the concepts and techniques described in Oracle Big Data Spatial Vector Hive Analysis, especially Using the Hive Spatial API.
The functions are presented alphabetically. However, they can be grouped into the following logical categories: types, single-geometry functions, and two-geometry functions.
Types:
Single-geometry functions:
Two-geometry functions:
Format
ST_AnyInteract( geometry1 ST_Geometry, geometry1 ST_Geometry, tolerance NUMBER DEFAULT 0 (nongeodetic geometries) or 0.05 (geodetic geometries));
Description
Determines if geometry1
has any spatial interaction with geometry2
, returning true
or false
.
Parameters
Usage Notes
Both geometries must have the same number of dimensions (2 or 3) and the same spatial reference system (SRID, or coordinate system).
See also Oracle Big Data Spatial Vector Hive Analysis for conceptual and usage information.
Examples
select ST_AnyInteract( ST_Point('{ "type": "Point", "coordinates": [2, 3]}', 8307), ST_Polygon('{"type": "Polygon","coordinates": [[[1, 2], [5, 2], [5, 6], [1, 6], [1, 2]]]}', 8307)) from hivetable LIMIT 1; -- return true
Format
ST_Area( geometry ST_Geometry tolerance NUMBER DEFAULT 0 (nongeodetic geometries) or 0.05 (geodetic geometries));
Description
Returns the area of a polygon or multipolygon geometry.
Parameters
Usage Notes
See Oracle Big Data Spatial Vector Hive Analysis for conceptual and usage information.
Examples
select ST_Area(ST_Polygon('{"type": "Polygon","coordinates": [[[1, 2], [5, 2], [5, 7], [1, 7], [1, 2]]]}', 0)) from hivetable LIMIT 1; -- return 20
Format
ST_AsWKB( geometry ST_Geometry);
Description
Returns the well-known binary (WKB) representation of the geometry.
Usage Notes
See Oracle Big Data Spatial Vector Hive Analysis for conceptual and usage information.
Examples
select ST_AsWKB( ST_Point('{ "type": "Point", "coordinates": [0, 5]}', 8307)) from hivetable LIMIT 1;
Format
ST_AsWKT( geometry ST_Geometry);
Description
Returns the well-known text (WKT) representation of the geometry.
Usage Notes
See Oracle Big Data Spatial Vector Hive Analysis for conceptual and usage information.
Examples
select ST_AsWKT(ST_Point('{ "type": "Point", "coordinates": [0, 5]}', 8307)) from hivetable LIMIT 1;
Format
ST_Buffer( geometry ST_Geometry, bufferWidth NUMBER, arcTol NUMBER DEFAULT 0 (nongeodetic geometries) or 0.05 (geodetic geometries));
Description
Generates a new ST_Geometry object that is the buffered version of the input geometry.
Parameters
Any 2D geometry object. If the geometry is geodetic, it is interpreted as longitude/latitude values in the WGS84 spatial reference system, and bufferWidth
and tolerance
are interpreted as meters.
The distance value used for the buffer.
Tolerance used for geodetic arc densification. (Ignored for nongeodetic geometries.)
Usage Notes
See Oracle Big Data Spatial Vector Hive Analysis for conceptual and usage information.
Examples
select ST_Buffer(ST_Point('{ "type": "Point", "coordinates": [0, 5]}', 0), 3) from hivetable LIMIT 1; -- return {"type":"Polygon", "coordinates":[[[-3,5],[0,2],[3,5]]],"crs":{"type":"name","properties":{"name":"EPSG:0"}}}
Format
ST_Contains( geometry1 ST_Geometry, geometry1 ST_Geometry, tolerance NUMBER DEFAULT 0 (nongeodetic geometries) or 0.05 (geodetic geometries));
Description
Determines if geometry1
contains geometry2
, returning true
or false
.
Parameters
Usage Notes
Both geometries must have the same number of dimensions (2 or 3) and the same spatial reference system (SRID, or coordinate system).
See also Oracle Big Data Spatial Vector Hive Analysis for conceptual and usage information.
Examples
select ST_Contains( ST_Polygon('{"type": "Polygon","coordinates": [[[1, 2], [5, 2], [5, 6], [1, 6], [1, 2]]]}', 8307), ST_Point('{ "type": "Point", "coordinates": [2, 3]}', 8307)) from hivetable LIMIT 1; -- return true
Format
ST_ConvexHull( geometry ST_Geometry);
Description
Returns the convex hull of the input geometry as an ST_Geometry object.
Usage Notes
See Oracle Big Data Spatial Vector Hive Analysis for conceptual and usage information.
Examples
select ST_ConvexHull( ST_MultiPoint(' { "type": "MultiPoint","coordinates": [ [1, 2], [-1, -2], [5, 6] ] }', 0)) from hivetable LIMIT 1; -- return {"type":"Polygon", "coordinates":[[[5,6],[1,2],[-1,-2],[5,6]]],"crs":{"type":"name","properties":{"name":"EPSG:0"}}}
Format
ST_Distance( geometry1 ST_Geometry, geometry1 ST_Geometry, tolerance NUMBER DEFAULT 0 (nongeodetic geometries) or 0.05 (geodetic geometries));
Description
Determines the distance between two 2D geometries.
Parameters
Usage Notes
This function returns thedistance between the two given geometries. For projected data, the distance is in the same unit as the unit of projection. For geodetic data, the distance is in meters.
If an error occurs, the function returns -1.
See also Oracle Big Data Spatial Vector Hive Analysis for conceptual and usage information.
Examples
select ST_Distance( ST_Point('{ "type": "Point", "coordinates": [0, 0]}', 0), ST_Point('{ "type": "Point", "coordinates": [6, 8]}', 0)) from hivetable LIMIT 1; -- return 10.0
Format
ST_Envelope( geometry ST_Geometry);
Description
Returns the envelope (bounding polygon) of the input geometry as an ST_Geometry object.
Usage Notes
See Oracle Big Data Spatial Vector Hive Analysis for conceptual and usage information.
Examples
select ST_Envelope( ST_MultiPoint(' { "type": "MultiPoint","coordinates": [ [1, 2], [-1, -2], [5, 6] ] }', 0)) from hivetable LIMIT 1; -- return {"type":"Polygon", "coordinates":[[[-1,-2],[5,-2],[5,6],[-1,6],[-1,-2]]],"crs":{"type":"name","properties":{"name":"EPSG:0"}}}
Format
ST_GEOMETRY( geometry STRING srid INT);
or
ST_GEOMETRY( geometry BINARY srid INT);
or
ST_GEOMETRY( geometry Object hiveRecordInfoProvider STRING);
Description
Creates a GeoJSON string representation of the geometry, and returns a GeoJSON string representation of the geometry.
Parameters
To create a geometry from a GeoJSON or WKT string (first format): Geometry definition in GeoJSON or WKT format.
To create a geometry from a WKB object (second format): Geometry definition in WKB format.
To create a geometry using a Hive object (third format): Geometry definition in any Hive supported type.
oracle.spatial.hadoop.vector.hive.HiveRecordInfoProvider
to extract the geometry in GeoJSON format.Usage Notes
See Oracle Big Data Spatial Vector Hive Analysis for conceptual and usage information.
Examples
-- creates a point using GeoJSON select ST_Geometry (' { "type": "Point", "coordinates": [100.0, 0.0]}', 8307) from hivetable LIMIT 1; -- creates a point using WKT select ST_Geometry ('point(100.0 0.0)', 8307) from hivetable LIMIT 1; -- creates the geometries using a HiveRecordInfoProvider select ST_Geometry (geoColumn, ‘hive.samples.SampleHiveRecordInfoProviderImpl’) from hivetable;
Format
ST_Inside( geometry1 ST_Geometry, geometry1 ST_Geometry, tolerance NUMBER DEFAULT 0 (nongeodetic geometries) or 0.05 (geodetic geometries));
Description
Determines if geometry1
is inside geometry2
, returning true
or false
.
Parameters
Usage Notes
Both geometries must have the same number of dimensions (2 or 3) and the same spatial reference system (SRID, or coordinate system).
See also Oracle Big Data Spatial Vector Hive Analysis for conceptual and usage information.
Examples
select ST_Inside( ST_Point('{ "type": "Point", "coordinates": [2, 3]}', 8307), ST_Polygon('{"type": "Polygon","coordinates": [[[1, 2], [5, 2], [5, 6], [1, 6], [1, 2]]]}', 8307)) from hivetable LIMIT 1; -- return true
Format
ST_Length( geometry ST_Geometry tolerance NUMBER DEFAULT 0 (nongeodetic geometries) or 0.05 (geodetic geometries));
Description
Returns the length of a line or polygon geometry.
Parameters
Usage Notes
See Oracle Big Data Spatial Vector Hive Analysis for conceptual and usage information.
Examples
select ST_Length(ST_Polygon('{"type": "Polygon","coordinates": [[[1, 2], [5, 2], [5, 6], [1, 6], [1, 2]]]}', 0)) from hivetable LIMIT 1; -- return 16
Format
ST_LineString( geometry STRING srid INT);
or
ST_LineString( geometry BINARY srid INT);
or
ST_LineString( geometry Object hiveRecordInfoProvider STRING);
Description
Creates a line string geometry in GeoJSON format, and returns a GeoJSON string representation of the geometry.
Parameters
To create a geometry from a GeoJSON or WKT string (first format): Geometry definition in GeoJSON or WKT format.
To create a geometry from a WKB object (second format): Geometry definition in WKB format.
To create a geometry using a Hive object (third format): Geometry definition in any Hive supported type.
oracle.spatial.hadoop.vector.hive.HiveRecordInfoProvider
to extract the geometry in GeoJSON format.Usage Notes
See Oracle Big Data Spatial Vector Hive Analysis for conceptual and usage information.
Examples
-- creates a line using GeoJSON select ST_LineString (' { "type": "LineString","coordinates": [ [100.0, 0.0], [101.0, 1.0] ]} ', 8307) from hivetable LIMIT 1; -- creates a line using WKT select ST_LineString (' linestring(1 1, 5 5, 10 10, 20 20)', 8307) from hivetable LIMIT 1; -- creates the lines using a HiveRecordInfoProvider select ST_LineString (geoColumn, ‘mypackage.hiveRecordInfoProviderImpl’) from hivetable;
Format
ST_MultiLineString( geometry STRING srid INT);
or
ST_MultiLineString( geometry BINARY srid INT);
or
ST_MultiLineString( geometry Object hiveRecordInfoProvider STRING);
Description
Creates a multiline string geometry in GeoJSON format, and returns a GeoJSON string representation of the geometry.
Parameters
To create a geometry from a GeoJSON or WKT string (first format): Geometry definition in GeoJSON or WKT format.
To create a geometry from a WKB object (second format): Geometry definition in WKB format.
To create a geometry using a Hive object (third format): Geometry definition in any Hive supported type.
oracle.spatial.hadoop.vector.hive.HiveRecordInfoProvider
to extract the geometry in GeoJSON format.Usage Notes
See Oracle Big Data Spatial Vector Hive Analysis for conceptual and usage information.
Examples
-- creates a MultiLineString using GeoJSON select ST_ MultiLineString (' { "type": "MultiLineString","coordinates": [ [ [100.0, 0.0], [101.0, 1.0] ], [ [102.0, 2.0], [103.0, 3.0] ]] }', 8307) from hivetable LIMIT 1; -- creates a MultiLineString using WKT select ST_ MultiLineString ('multilinestring ((10 10, 20 20, 10 40), (40 40, 30 30, 40 20, 30 10))', 8307) from hivetable LIMIT 1; -- creates MultiLineStrings using a HiveRecordInfoProvider select ST_ MultiLineString (geoColumn, ‘mypackage.hiveRecordInfoProviderImpl’) from hivetable;
Format
ST_MultiPoint( geometry STRING srid INT);
or
ST_MultiPoint( geometry BINARY srid INT);
or
ST_MultiPoint( geometry Object hiveRecordInfoProvider STRING);
Description
Creates a multipoint geometry in GeoJSON format, and returns a GeoJSON string representation of the geometry.
Parameters
To create a geometry from a GeoJSON or WKT string (first format): Geometry definition in GeoJSON or WKT format.
To create a geometry from a WKB object (second format): Geometry definition in WKB format.
To create a geometry using a Hive object (third format): Geometry definition in any Hive supported type.
oracle.spatial.hadoop.vector.hive.HiveRecordInfoProvider
to extract the geometry in GeoJSON format.Usage Notes
See Oracle Big Data Spatial Vector Hive Analysis for conceptual and usage information.
Examples
-- creates a MultiPoint using GeoJSON select ST_MultiPoint (' { "type": "MultiPoint","coordinates": [ [100.0, 0.0], [101.0, 1.0] ] }', 8307) from hivetable LIMIT 1; -- creates a MultiPoint using WKT select ST_ MultiPoint ('multipoint ((10 40), (40 30), (20 20), (30 10))', 8307) from hivetable LIMIT 1; -- creates MultiPoints using a HiveRecordInfoProvider select ST_ MultiPoint (geoColumn, ‘mypackage.hiveRecordInfoProviderImpl’) from hivetable;
Format
ST_MultiPolygon( geometry STRING srid INT);
or
ST_MultiPolygon( geometry BINARY srid INT);
or
ST_MultiPolygon( geometry Object hiveRecordInfoProvider STRING);
Description
Creates a multipolygon geometry in GeoJSON format, and returns a GeoJSON string representation of the geometry.
Parameters
To create a geometry from a GeoJSON or WKT string (first format): Geometry definition in GeoJSON or WKT format.
To create a geometry from a WKB object (second format): Geometry definition in WKB format.
To create a geometry using a Hive object (third format): Geometry definition in any Hive supported type.
oracle.spatial.hadoop.vector.hive.HiveRecordInfoProvider
to extract the geometry in GeoJSON format.Usage Notes
See Oracle Big Data Spatial Vector Hive Analysis for conceptual and usage information.
Examples
-- creates a MultiPolygon using GeoJSON select ST_ MultiPolygon (' { "type": "MultiPolygon","coordinates": [[[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]], [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]], [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]] ] }', 8307) from hivetable LIMIT 1; -- creates a MultiPolygon using WKT select ST_ MultiPolygon ('multipolygon(((30 20, 45 40, 10 40, 30 20)), ((15 5, 40 10, 10 20, 5 10, 15 5)))', 8307) from hivetable LIMIT 1; -- creates MultiPolygons using a HiveRecordInfoProvider select ST_ MultiPolygon (geoColumn, ‘mypackage.hiveRecordInfoProviderImpl’) from hivetable;
Format
ST_Point( geometry STRING srid INT);
or
ST_Point( geometry BINARY srid INT);
or
ST_Point( geometry Object hiveRecordInfoProvider STRING);
Description
Creates a point geometry in GeoJSON format, and returns a GeoJSON string representation of the geometry.
Parameters
To create a geometry from a GeoJSON or WKT string (first format): Geometry definition in GeoJSON or WKT format.
To create a geometry from a WKB object (second format): Geometry definition in WKB format.
To create a geometry using a Hive object (third format): Geometry definition in any Hive supported type.
oracle.spatial.hadoop.vector.hive.HiveRecordInfoProvider
to extract the geometry in GeoJSON format.Usage Notes
See Oracle Big Data Spatial Vector Hive Analysis for conceptual and usage information.
Examples
-- creates a point using GeoJSON select ST_Point (' { "type": "Point", "coordinates": [100.0, 0.0]}', 8307) from hivetable LIMIT 1; -- creates a point using WKT select ST_Point ('point(100.0 0.0)', 8307) from hivetable LIMIT 1; -- creates the points using a HiveRecordInfoProvider select ST_Point (geoColumn, ‘hive.samples.SampleHiveRecordInfoProviderImpl’) from hivetable;
Format
ST_Polygon( geometry STRING srid INT);
or
ST_Polygon( geometry BINARY srid INT);
or
ST_Polygon( geometry Object hiveRecordInfoProvider STRING);
Description
Creates a polygon geometry in GeoJSON format, and returns a GeoJSON string representation of the geometry.
Parameters
To create a geometry from a GeoJSON or WKT string (first format): Geometry definition in GeoJSON or WKT format.
To create a geometry from a WKB object (second format): Geometry definition in WKB format.
To create a geometry using a Hive object (third format): Geometry definition in any Hive supported type.
oracle.spatial.hadoop.vector.hive.HiveRecordInfoProvider
to extract the geometry in GeoJSON format.Usage Notes
See Oracle Big Data Spatial Vector Hive Analysis for conceptual and usage information.
Examples
-- creates a polygon using GeoJSON select ST_Polygon (' { "type": "Polygon","coordinates": [ [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]] }', 8307) from hivetable LIMIT 1; -- creates a polygon using WKT select ST_ Polygon ('polygon((0 0, 10 0, 10 10, 0 0))', 8307) from hivetable LIMIT 1; -- creates the polygons using a HiveRecordInfoProvider select ST_ Polygon (geoColumn, ‘mypackage.hiveRecordInfoProviderImpl’) from hivetable;
Format
ST_Simplify( geometry ST_Geometry, threshold NUMBER);
Description
Generates a new ST_Geometry object by simplifying the input geometry using the Douglas-Peucker algorithm.
Parameters
Any 2D geometry object. If the geometry is geodetic, it is interpreted as longitude/latitude values in the WGS84 spatial reference system, and bufferWidth
and tolerance
are interpreted as meters.
Threshold value to be used for the geometry simplification. Should be a positive number. (Zero causes the input geometry to be returned.) If the input geometry is geodetic, the value is the number of meters; if the input geometry is non-geodetic, the value is the number of units associated with the data.
As the threshold value is decreased, the generated geometry is likely to be closer to the input geometry; as the threshold value is increased, fewer vertices are likely to be in the returned geometry.
Usage Notes
Depending on the threshold value, a polygon can simplify into a line or a point, and a line can simplify into a point. Therefore, the output object should be checked for type, because the output geometry type might be different from the input geometry type.
See also Oracle Big Data Spatial Vector Hive Analysis for conceptual and usage information.
Examples
select ST_Simplify( ST_Polygon('{"type": "Polygon","coordinates": [[[1, 2], [1.01, 2.01], [5, 2], [5, 6], [1, 6], [1, 2]]]}', 8307), 1) from hivetable LIMIT 1; -- return {"type":"Polygon", "coordinates":[[[1,2],[5,2],[5,6],[1,6],[1,2]]],"crs":{"type":"name","properties":{"name":"EPSG:8307"}}}
Format
ST_SimplifyVW( geometry ST_Geometry, threshold NUMBER);
Description
Generates a new ST_Geometry object by simplifying the input geometry using the Visvalingham-Whyatt algorithm.
Parameters
Any 2D geometry object. If the geometry is geodetic, it is interpreted as longitude/latitude values in the WGS84 spatial reference system, and bufferWidth
and tolerance
are interpreted as meters.
Threshold value to be used for the geometry simplification. Should be a positive number. (Zero causes the input geometry to be returned.) If the input geometry is geodetic, the value is the number of meters; if the input geometry is non-geodetic, the value is the number of units associated with the data.
As the threshold value is decreased, the generated geometry is likely to be closer to the input geometry; as the threshold value is increased, fewer vertices are likely to be in the returned geometry.
Usage Notes
Depending on the threshold value, a polygon can simplify into a line or a point, and a line can simplify into a point. Therefore, the output object should be checked for type, because the output geometry type might be different from the input geometry type.
See also Oracle Big Data Spatial Vector Hive Analysis for conceptual and usage information.
Examples
select ST_SimplifyVW( ST_Polygon('{"type": "Polygon","coordinates": [[[1, 2], [1.01, 2.01], [5, 2], [5, 6], [1, 6], [1, 2]]]}', 8307), 50) from hivetable LIMIT 1; -- return {"type":"Polygon", "coordinates":[[[1,2],[5,6],[1,6],[1,2]]],"crs":{"type":"name","properties":{"name":"EPSG:8307"}}}
Format
ST_Volume( multipolygon ST_MultiPolygon, tolerance NUMBER DEFAULT 0 (nongeodetic geometries) or 0.05 (geodetic geometries));
Description
Returns the area of a multipolygon 3D geometry. The multipolygon is handled as a solid.
Parameters
Usage Notes
For projected data, the volume is in the same unit as the unit of projection. For geodetic data, the volume is in cubic meters.
Returns -1 in case of an error.
See also Oracle Big Data Spatial Vector Hive Analysis for conceptual and usage information.
Examples
select select ST_Volume( ST_MultiPolygon (' { "type": "MultiPolygon", "coordinates": [[[[0, 0, 0], [0, 0, 1], [0, 1, 1], [0, 1, 0], [0, 0, 0]]], [[[0, 0, 0], [0, 1, 0], [1, 1, 0], [1, 0, 0], [0, 0, 0]]], [[[0, 0, 0], [1, 0, 0], [1, 0, 1], [0, 0, 1], [0, 0, 0]]], [[[1, 1, 0], [1, 1, 1], [1, 0, 1], [1, 0, 0], [1, 1, 0]]], [[[0, 1, 0], [0, 1, 1], [1, 1, 1], [1, 1, 0], [0, 1, 0]]], [[[0, 0, 1], [1, 0, 1], [1, 1, 1], [0, 1, 1], [0, 0, 1]]]]}', 0)) from hivetable LIMIT 1; -- return 1.0