<html>
<head>
    <base href="https://docs.jboss.org/author">
            <link rel="stylesheet" href="/author/s/en/2172/19/5/_/styles/combined.css?spaceKey=TEIID&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://docs.jboss.org/author/display/TEIID/Spatial+Functions">Spatial Functions</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://docs.jboss.org/author/display/~shawkins">Steven Hawkins</a>
    </h4>
        <br/>
                         <h4>Changes (2)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{code:SQL}ST_AsKML(geom){code} <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >geom is a geometry. Return value is a clob with the KML value.  The KML value is effectively a simplified GML value and <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">restricted only to geometry values with</span> <span class="diff-added-words"style="background-color: #dfd;">projected into</span> SRID <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">=</span> 4326. <br></td></tr>
            <tr><td class="diff-unchanged" > <br>h1. Relationship Functions <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>geom is a geometry. srid is an integer. Return value is a geometry. Only the SRID metadata of the geometry is modified. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;"> <br>h2. ST_TRANSFORM <br> <br>Transforms the geometry value from one coordinate system to another. <br> <br>{code:SQL}ST_TRANSFORM(geom, srid){code} <br> <br>geom is a geometry. srid is an integer. Return value is a geometry. The srid value and the srid of the geometry value must exist in the SPATIAL_REF_SYS view. <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p>Spatial functions provide functionality for working with <a href="http://www.opengeospatial.org/" class="external-link" rel="nofollow">geospatial</a> data.  Teiid relies on the <a href="http://www.vividsolutions.com/jts/JTSHome.htm" class="external-link" rel="nofollow">JTS Topology Suite</a> to provide partial support for the OpenGIS Simple Features Specification For SQL Revision 1.1.  Please refer to the <a href="https://portal.opengeospatial.org/files/?artifact_id=829" class="external-link" rel="nofollow">specification</a> for more details about particular functions.</p>

<p>Most Geometry support is limited to two dimensions due to the WKB and WKT formats.</p>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Geometry support is still evolving.  There may be minor differences between Teiid and pushdown results that will need to be further refined.</td></tr></table></div>

<h1><a name="SpatialFunctions-ConversionFunctions"></a>Conversion Functions</h1>

<h2><a name="SpatialFunctions-STGeomFromText"></a>ST_GeomFromText</h2>

<p>Returns a geometry from a Clob in WKT format.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">ST_GeomFromText(text [, srid])</pre>
</div></div>

<p>text is a clob, srid is an optional integer. Return value is a geometry.</p>

<h2><a name="SpatialFunctions-STGeomFromWKB%2FSTGeomFromBinary"></a>ST_GeomFromWKB/ST_GeomFromBinary</h2>

<p>Returns a geometry from a blob in WKB format.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">ST_GeomFromWKB(bin [, srid])</pre>
</div></div>

<p>bin is a blob, srid is an optional integer. Return value is a geometry.</p>

<h2><a name="SpatialFunctions-STGeomFromGeoJSON"></a>ST_GeomFromGeoJSON</h2>

<p>Returns a geometry from a Clob in GeoJSON format.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">ST_GeomFromGeoJson(text [, srid])</pre>
</div></div>

<p>text is a clob, srid is an optional integer. Return value is a geometry.</p>

<h2><a name="SpatialFunctions-STGeomFromGML"></a>ST_GeomFromGML</h2>

<p>Returns a geometry from a Clob in GML2 format.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">ST_GeomFromGML(text [, srid])</pre>
</div></div>

<p>text is a clob, srid is an optional integer. Return value is a geometry.</p>

<h2><a name="SpatialFunctions-STAsText"></a>ST_AsText</h2>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">ST_GeomAsText(geom)</pre>
</div></div>

<p>geom is a geometry. Return value is clob in WKT format.</p>

<h2><a name="SpatialFunctions-STAsBinary"></a>ST_AsBinary</h2>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">ST_GeomAsBinary(geom)</pre>
</div></div>

<p>geom is a geometry. Return value is a blob in WKB format.</p>

<h2><a name="SpatialFunctions-STAsGeoJSON"></a>ST_AsGeoJSON</h2>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">ST_GeomAsGeoJSON(geom)</pre>
</div></div>

<p>geom is a geometry. Return value is a clob with the GeoJSON value.</p>

<h2><a name="SpatialFunctions-STAsGML"></a>ST_AsGML</h2>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">ST_GeomAsGML(geom)</pre>
</div></div>

<p>geom is a geometry. Return value is a clob with the GML2 value.</p>

<h2><a name="SpatialFunctions-STAsEWKT"></a>ST_AsEWKT</h2>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">ST_AsEWKT(geom)</pre>
</div></div>

<p>geom is a geometry. Return value is a clob with the EWKT value.  The EWKT value is the WKT value with the SRID prefix.</p>

<h2><a name="SpatialFunctions-STAsKML"></a>ST_AsKML</h2>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">ST_AsKML(geom)</pre>
</div></div>

<p>geom is a geometry. Return value is a clob with the KML value.  The KML value is effectively a simplified GML value and projected into SRID 4326.</p>

<h1><a name="SpatialFunctions-RelationshipFunctions"></a>Relationship Functions</h1>

<h2><a name="SpatialFunctions-STCONTAINS"></a>ST_CONTAINS</h2>

<p>Returns true if geom1 contains geom2 contains another.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">ST_CONTAINS(geom1, geom2)</pre>
</div></div>

<p>geom1, geom2 are geometries. Return value is a boolean.</p>

<h2><a name="SpatialFunctions-STCROSSES"></a>ST_CROSSES</h2>

<p>Returns true if the geometries cross.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">ST_CROSSES(geom1, geom2)</pre>
</div></div>

<p>geom1, geom2 are geometries. Return value is a boolean.</p>

<h2><a name="SpatialFunctions-STDISJOINT"></a>ST_DISJOINT</h2>

<p>Returns true if the geometries are disjoint.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">ST_DISJOINT(geom1, geom2)</pre>
</div></div>

<p>geom1, geom2 are geometries. Return value is a boolean.</p>

<h2><a name="SpatialFunctions-STDISTANCE"></a>ST_DISTANCE</h2>

<p>Returns the distance between two geometries.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">ST_DISTANCE(geom1, geom2)</pre>
</div></div>

<p>geom1, geom2 are geometries. Return value is a double.</p>

<h2><a name="SpatialFunctions-STEQUALS"></a>ST_EQUALS</h2>

<p>Returns true if the two geometries are spatially equal - the points and order may differ, but neither geometry lies outside of the other.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">ST_EQUALS(geom1, geom2)</pre>
</div></div>

<p>geom1, geom2 are geometries. Return value is a boolean.</p>

<h2><a name="SpatialFunctions-STINTERSECTS"></a>ST_INTERSECTS</h2>

<p>Returns true if the geometries intersect.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">ST_INTERSECT(geom1, geom2)</pre>
</div></div>

<p>geom1, geom2 are geometries. Return value is a boolean.</p>

<h2><a name="SpatialFunctions-STOVERLAPS"></a>ST_OVERLAPS</h2>

<p>Returns true if the geometries overlap.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">ST_OVERLAPS(geom1, geom2)</pre>
</div></div>

<p>geom1, geom2 are geometries. Return value is a boolean.</p>

<h2><a name="SpatialFunctions-STTOUCHES"></a>ST_TOUCHES</h2>

<p>Returns true if the geometries touch.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">ST_TOUCHES(geom1, geom2)</pre>
</div></div>

<p>geom1, geom2 are geometries. Return value is a boolean.</p>

<h1><a name="SpatialFunctions-Misc.Functions"></a>Misc. Functions</h1>

<h2><a name="SpatialFunctions-STSRID"></a>ST_SRID</h2>

<p>Returns the SRID for the geometry.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">ST_SRID(geom)</pre>
</div></div>

<p>geom is a geometry. Return value is an integer. A 0 value rather than null will be returned for an unknown SRID on a non-null geometry.</p>

<h2><a name="SpatialFunctions-STSetSRID"></a>ST_SetSRID</h2>

<p>Set the SRID for the given geometry.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">ST_SetSRID(geom, srid)</pre>
</div></div>

<p>geom is a geometry. srid is an integer. Return value is a geometry. Only the SRID metadata of the geometry is modified.</p>

<h2><a name="SpatialFunctions-STTRANSFORM"></a>ST_TRANSFORM</h2>

<p>Transforms the geometry value from one coordinate system to another.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">ST_TRANSFORM(geom, srid)</pre>
</div></div>

<p>geom is a geometry. srid is an integer. Return value is a geometry. The srid value and the srid of the geometry value must exist in the SPATIAL_REF_SYS view.</p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://docs.jboss.org/author/users/removespacenotification.action?spaceKey=TEIID">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://docs.jboss.org/author/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
        <a href="https://docs.jboss.org/author/display/TEIID/Spatial+Functions">View Online</a>
        |
        <a href="https://docs.jboss.org/author/pages/diffpagesbyversion.action?pageId=88866956&revisedVersion=11&originalVersion=10">View Changes</a>
                |
        <a href="https://docs.jboss.org/author/display/TEIID/Spatial+Functions?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>