<sect1 id="Raster_Relationships">
<title>Raster and Raster Band Spatial Relationships</title>
- <refentry id="RT_ST_Intersects">
- <refnamediv>
- <refname>ST_Intersects</refname>
-
- <refpurpose>Return true if raster rastA spatially intersects raster rastB.</refpurpose>
- </refnamediv>
- <refsynopsisdiv>
- <funcsynopsis>
+ <refentry id="RT_ST_Contains">
+ <refnamediv>
+ <refname>ST_Contains</refname>
+ <refpurpose>
+ Return true if no points of raster rastB lie in the exterior of raster rastA and at least one point of the interior of rastB lies in the interior of rastA.
+ </refpurpose>
+ </refnamediv>
- <funcprototype>
- <funcdef>boolean <function>ST_Intersects</function></funcdef>
+ <refsynopsisdiv>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>boolean <function>ST_Contains</function></funcdef>
<paramdef>
<type>raster </type>
<parameter>rastA</parameter>
<type>integer </type>
<parameter>nbandB</parameter>
</paramdef>
- </funcprototype>
+ </funcprototype>
<funcprototype>
- <funcdef>boolean <function>ST_Intersects</function></funcdef>
+ <funcdef>boolean <function>ST_Contains</function></funcdef>
<paramdef>
<type>raster </type>
<parameter>rastA</parameter>
<type>raster </type>
<parameter>rastB</parameter>
</paramdef>
- </funcprototype>
+ </funcprototype>
+
+ </funcsynopsis>
+ </refsynopsisdiv>
+
+ <refsection>
+ <title>Description</title>
+
+ <para>
+ Raster rastA contains rastB if and only if no points of rastB lie in the exterior of rastA and at least one point of the interior of rastB lies in the interior of rastA. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
+ </para>
+
+ <note>
+ <para>
+ This function will make use of any indexes that may be available on the rasters.
+ </para>
+ </note>
+ <note>
+ <para>
+ To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Contains(ST_Polygon(raster), geometry) or ST_Contains(geometry, ST_Polygon(raster)).
+ </para>
+ </note>
+
+ <note>
+ <para>
+ ST_Contains() is the inverse of ST_Within(). So, ST_Contains(rastA, rastB) implies ST_Within(rastB, rastA).
+ </para>
+ </note>
+
+ <para>Availability: 2.1.0</para>
+ </refsection>
+
+ <refsection>
+ <title>Examples</title>
+
+ <programlisting>
+-- needs an example
+ </programlisting>
+ </refsection>
+ <refsection>
+ <title>See Also</title>
+ <para>
+ <xref linkend="RT_ST_Intersects" />,
+ <xref linkend="RT_ST_Within" />
+ </para>
+ </refsection>
+ </refentry>
+
+ <refentry id="RT_ST_ContainsProperly">
+ <refnamediv>
+ <refname>ST_ContainsProperly</refname>
+ <refpurpose>
+ Return true if rastB intersects the interior of rastA but not the boundary or exterior of rastA.
+ </refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <funcsynopsis>
<funcprototype>
- <funcdef>boolean <function>ST_Intersects</function></funcdef>
- <paramdef>
- <type>raster </type>
- <parameter>rast</parameter>
- </paramdef>
+ <funcdef>boolean <function>ST_ContainsProperly</function></funcdef>
<paramdef>
- <type>integer </type>
- <parameter>nband</parameter>
+ <type>raster </type>
+ <parameter>rastA</parameter>
</paramdef>
<paramdef>
- <type>geometry </type>
- <parameter>geommin</parameter>
+ <type>integer </type>
+ <parameter>nbandA</parameter>
</paramdef>
- </funcprototype>
-
- <funcprototype>
- <funcdef>boolean <function>ST_Intersects</function></funcdef>
<paramdef>
- <type>raster </type>
- <parameter>rast</parameter>
+ <type>raster </type>
+ <parameter>rastB</parameter>
</paramdef>
<paramdef>
- <type>geometry </type>
- <parameter>geommin</parameter>
- </paramdef>
- <paramdef choice='opt'>
- <type>integer </type>
- <parameter>nband=NULL</parameter>
+ <type>integer </type>
+ <parameter>nbandB</parameter>
</paramdef>
- </funcprototype>
+ </funcprototype>
- <funcprototype>
- <funcdef>boolean <function>ST_Intersects</function></funcdef>
+ <funcprototype>
+ <funcdef>boolean <function>ST_ContainsProperly</function></funcdef>
<paramdef>
- <type>geometry </type>
- <parameter>geommin</parameter>
+ <type>raster </type>
+ <parameter>rastA</parameter>
</paramdef>
<paramdef>
- <type>raster </type>
- <parameter>rast</parameter>
- </paramdef>
- <paramdef choice='opt'>
- <type>integer </type>
- <parameter>nband=NULL</parameter>
+ <type>raster </type>
+ <parameter>rastB</parameter>
</paramdef>
- </funcprototype>
+ </funcprototype>
</funcsynopsis>
- </refsynopsisdiv>
+ </refsynopsisdiv>
- <refsection>
+ <refsection>
<title>Description</title>
<para>
- Return true if raster rastA spatially intersects raster rastB. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
+ Raster rastA contains properly rastB if rastB intersects the interior of rastA but not the boundary or exterior of rastA. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
+ </para>
+
+ <para>
+ Raster rastA does not contain properly itself but does contain itself.
</para>
<note>
<para>
- This operand will make use of any indexes that may be available on the rasters.
+ This function will make use of any indexes that may be available on the rasters.
</para>
</note>
-
- <para>
- Enhanced: 2.0.0 support raster/raster intersects was introduced.
- </para>
- <warning>
+ <note>
<para>
- Changed: 2.1.0 The behavior of the ST_Intersects(raster, geometry) variants changed to match that of ST_Intersects(geometry, raster).
+ To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_ContainsProperly(ST_Polygon(raster), geometry) or ST_ContainsProperly(geometry, ST_Polygon(raster)).
</para>
- </warning>
+ </note>
- </refsection>
+ <para>Availability: 2.1.0</para>
+ </refsection>
- <refsection>
+ <refsection>
<title>Examples</title>
<programlisting>
--- needs a new example
+-- needs an example
</programlisting>
- </refsection>
- <refsection>
- <title>See Also</title>
- <para>
- <xref linkend="RT_ST_Intersection" />
- </para>
- </refsection>
- </refentry>
+ </refsection>
+ <refsection>
+ <title>See Also</title>
+ <para>
+ <xref linkend="RT_ST_Intersects" />,
+ <xref linkend="RT_ST_Contains" />
+ </para>
+ </refsection>
+ </refentry>
- <refentry id="RT_ST_Overlaps">
+ <refentry id="RT_ST_Covers">
<refnamediv>
- <refname>ST_Overlaps</refname>
+ <refname>ST_Covers</refname>
<refpurpose>
- Return true if raster rastA and rastB intersect but one does not completely contain the other.
+ Return true if no points of raster rastB lie outside raster rastA.
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
- <funcdef>boolean <function>ST_Overlaps</function></funcdef>
+ <funcdef>boolean <function>ST_Covers</function></funcdef>
<paramdef>
<type>raster </type>
<parameter>rastA</parameter>
</funcprototype>
<funcprototype>
- <funcdef>boolean <function>ST_Overlaps</function></funcdef>
+ <funcdef>boolean <function>ST_Covers</function></funcdef>
<paramdef>
<type>raster </type>
<parameter>rastA</parameter>
<title>Description</title>
<para>
- Return true if raster rastA spatially overlaps raster rastB. This means that rastA and rastB intersect but one does not completely contain the other. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
+ Raster rastA covers rastB if and only if no points of rastB lie in the exterior of rastA. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
</para>
<note>
<para>
- This operand will make use of any indexes that may be available on the rasters.
+ This function will make use of any indexes that may be available on the rasters.
</para>
</note>
<note>
<para>
- To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Overlaps(ST_Polygon(raster), geometry).
+ To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Covers(ST_Polygon(raster), geometry) or ST_Covers(geometry, ST_Polygon(raster)).
</para>
</note>
-
+
<para>Availability: 2.1.0</para>
</refsection>
<refsection>
<title>See Also</title>
<para>
- <xref linkend="RT_ST_Intersects" />
+ <xref linkend="RT_ST_Intersects" />,
+ <xref linkend="RT_ST_CoveredBy" />
</para>
</refsection>
</refentry>
- <refentry id="RT_ST_Touches">
+ <refentry id="RT_ST_CoveredBy">
<refnamediv>
- <refname>ST_Touches</refname>
+ <refname>ST_CoveredBy</refname>
<refpurpose>
- Return true if raster rastA and rastB have at least one point in common but their interiors do not intersect.
+ Return true if no points of raster rastA lie outside raster rastB.
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
- <funcdef>boolean <function>ST_Touches</function></funcdef>
+ <funcdef>boolean <function>ST_CoveredBy</function></funcdef>
<paramdef>
<type>raster </type>
<parameter>rastA</parameter>
</funcprototype>
<funcprototype>
- <funcdef>boolean <function>ST_Touches</function></funcdef>
+ <funcdef>boolean <function>ST_CoveredBy</function></funcdef>
<paramdef>
<type>raster </type>
<parameter>rastA</parameter>
<title>Description</title>
<para>
- Return true if raster rastA spatially touches raster rastB. This means that rastA and rastB have at least one point in common but their interiors do not intersect. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
+ Raster rastA is covered by rastB if and only if no points of rastA lie in the exterior of rastB. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
</para>
<note>
<para>
- This operand will make use of any indexes that may be available on the rasters.
+ This function will make use of any indexes that may be available on the rasters.
</para>
</note>
<note>
<para>
- To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Touches(ST_Polygon(raster), geometry).
+ To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_CoveredBy(ST_Polygon(raster), geometry) or ST_CoveredBy(geometry, ST_Polygon(raster)).
</para>
</note>
<refsection>
<title>See Also</title>
<para>
- <xref linkend="RT_ST_Intersects" />
+ <xref linkend="RT_ST_Intersects" />,
+ <xref linkend="RT_ST_Covers" />
</para>
</refsection>
</refentry>
- <refentry id="RT_ST_Contains">
+ <refentry id="RT_ST_Disjoint">
<refnamediv>
- <refname>ST_Contains</refname>
+ <refname>ST_Disjoint</refname>
<refpurpose>
- Return true if no points of raster rastB lie in the exterior of raster rastA and at least one point of the interior of rastB lies in the interior of rastA.
+ Return true if raster rastA does not spatially intersect rastB.
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
- <funcdef>boolean <function>ST_Contains</function></funcdef>
+ <funcdef>boolean <function>ST_Disjoint</function></funcdef>
<paramdef>
<type>raster </type>
<parameter>rastA</parameter>
</funcprototype>
<funcprototype>
- <funcdef>boolean <function>ST_Contains</function></funcdef>
+ <funcdef>boolean <function>ST_Disjoint</function></funcdef>
<paramdef>
<type>raster </type>
<parameter>rastA</parameter>
<title>Description</title>
<para>
- Raster rastA contains rastB if and only if no points of rastB lie in the exterior of rastA and at least one point of the interior of rastB lies in the interior of rastA. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
+ Raster rastA and rastB are disjointed if they do not share any space together. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
</para>
<note>
<para>
- This operand will make use of any indexes that may be available on the rasters.
- </para>
- </note>
-
- <note>
- <para>
- To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Contains(ST_Polygon(raster), geometry) or ST_Contains(geometry, ST_Polygon(raster)).
+ This function does NOT use any indexes.
</para>
</note>
<note>
<para>
- ST_Contains() is the inverse of ST_Within(). So, ST_Contains(rastA, rastB) implies ST_Within(rastB, rastA).
+ To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Disjoint(ST_Polygon(raster), geometry).
</para>
</note>
<refsection>
<title>See Also</title>
<para>
- <xref linkend="RT_ST_Intersects" />,
- <xref linkend="RT_ST_Within" />
+ <xref linkend="RT_ST_Intersects" />
</para>
</refsection>
</refentry>
- <refentry id="RT_ST_ContainsProperly">
+ <refentry id="RT_ST_Intersects">
<refnamediv>
- <refname>ST_ContainsProperly</refname>
- <refpurpose>
- Return true if rastB intersects the interior of rastA but not the boundary or exterior of rastA.
- </refpurpose>
+ <refname>ST_Intersects</refname>
+ <refpurpose>Return true if raster rastA spatially intersects raster rastB.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
- <funcdef>boolean <function>ST_ContainsProperly</function></funcdef>
+ <funcdef>boolean <function>ST_Intersects</function></funcdef>
<paramdef>
<type>raster </type>
<parameter>rastA</parameter>
</funcprototype>
<funcprototype>
- <funcdef>boolean <function>ST_ContainsProperly</function></funcdef>
+ <funcdef>boolean <function>ST_Intersects</function></funcdef>
<paramdef>
<type>raster </type>
<parameter>rastA</parameter>
</paramdef>
</funcprototype>
+ <funcprototype>
+ <funcdef>boolean <function>ST_Intersects</function></funcdef>
+ <paramdef>
+ <type>raster </type>
+ <parameter>rast</parameter>
+ </paramdef>
+ <paramdef>
+ <type>integer </type>
+ <parameter>nband</parameter>
+ </paramdef>
+ <paramdef>
+ <type>geometry </type>
+ <parameter>geommin</parameter>
+ </paramdef>
+ </funcprototype>
+
+ <funcprototype>
+ <funcdef>boolean <function>ST_Intersects</function></funcdef>
+ <paramdef>
+ <type>raster </type>
+ <parameter>rast</parameter>
+ </paramdef>
+ <paramdef>
+ <type>geometry </type>
+ <parameter>geommin</parameter>
+ </paramdef>
+ <paramdef choice='opt'>
+ <type>integer </type>
+ <parameter>nband=NULL</parameter>
+ </paramdef>
+ </funcprototype>
+
+ <funcprototype>
+ <funcdef>boolean <function>ST_Intersects</function></funcdef>
+ <paramdef>
+ <type>geometry </type>
+ <parameter>geommin</parameter>
+ </paramdef>
+ <paramdef>
+ <type>raster </type>
+ <parameter>rast</parameter>
+ </paramdef>
+ <paramdef choice='opt'>
+ <type>integer </type>
+ <parameter>nband=NULL</parameter>
+ </paramdef>
+ </funcprototype>
+
</funcsynopsis>
</refsynopsisdiv>
<title>Description</title>
<para>
- Raster rastA contains properly rastB if rastB intersects the interior of rastA but not the boundary or exterior of rastA. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
- </para>
-
- <para>
- Raster rastA does not contain properly itself but does contain itself.
+ Return true if raster rastA spatially intersects raster rastB. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
</para>
<note>
<para>
- This operand will make use of any indexes that may be available on the rasters.
+ This function will make use of any indexes that may be available on the rasters.
</para>
</note>
- <note>
+ <para>
+ Enhanced: 2.0.0 support raster/raster intersects was introduced.
+ </para>
+
+ <warning>
<para>
- To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_ContainsProperly(ST_Polygon(raster), geometry) or ST_ContainsProperly(geometry, ST_Polygon(raster)).
+ Changed: 2.1.0 The behavior of the ST_Intersects(raster, geometry) variants changed to match that of ST_Intersects(geometry, raster).
</para>
- </note>
+ </warning>
- <para>Availability: 2.1.0</para>
</refsection>
<refsection>
<title>Examples</title>
-
<programlisting>
--- needs an example
+-- needs a new example
</programlisting>
</refsection>
+
<refsection>
<title>See Also</title>
<para>
- <xref linkend="RT_ST_Intersects" />,
- <xref linkend="RT_ST_Contains" />
+ <xref linkend="RT_ST_Intersection" />,
+ <xref linkend="RT_ST_Disjoint" />
</para>
</refsection>
</refentry>
- <refentry id="RT_ST_Covers">
+ <refentry id="RT_ST_Overlaps">
<refnamediv>
- <refname>ST_Covers</refname>
+ <refname>ST_Overlaps</refname>
<refpurpose>
- Return true if no points of raster rastB lie outside raster rastA.
+ Return true if raster rastA and rastB intersect but one does not completely contain the other.
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
- <funcdef>boolean <function>ST_Covers</function></funcdef>
+ <funcdef>boolean <function>ST_Overlaps</function></funcdef>
<paramdef>
<type>raster </type>
<parameter>rastA</parameter>
</funcprototype>
<funcprototype>
- <funcdef>boolean <function>ST_Covers</function></funcdef>
+ <funcdef>boolean <function>ST_Overlaps</function></funcdef>
<paramdef>
<type>raster </type>
<parameter>rastA</parameter>
<title>Description</title>
<para>
- Raster rastA covers rastB if and only if no points of rastB lie in the exterior of rastA. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
+ Return true if raster rastA spatially overlaps raster rastB. This means that rastA and rastB intersect but one does not completely contain the other. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
</para>
<note>
<para>
- This operand will make use of any indexes that may be available on the rasters.
+ This function will make use of any indexes that may be available on the rasters.
</para>
</note>
<note>
<para>
- To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Covers(ST_Polygon(raster), geometry) or ST_Covers(geometry, ST_Polygon(raster)).
+ To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Overlaps(ST_Polygon(raster), geometry).
</para>
</note>
-
+
<para>Availability: 2.1.0</para>
</refsection>
<refsection>
<title>See Also</title>
<para>
- <xref linkend="RT_ST_Intersects" />,
- <xref linkend="RT_ST_CoveredBy" />
+ <xref linkend="RT_ST_Intersects" />
</para>
</refsection>
</refentry>
- <refentry id="RT_ST_CoveredBy">
+ <refentry id="RT_ST_Touches">
<refnamediv>
- <refname>ST_CoveredBy</refname>
+ <refname>ST_Touches</refname>
<refpurpose>
- Return true if no points of raster rastA lie outside raster rastB.
+ Return true if raster rastA and rastB have at least one point in common but their interiors do not intersect.
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
- <funcdef>boolean <function>ST_CoveredBy</function></funcdef>
+ <funcdef>boolean <function>ST_Touches</function></funcdef>
<paramdef>
<type>raster </type>
<parameter>rastA</parameter>
</funcprototype>
<funcprototype>
- <funcdef>boolean <function>ST_CoveredBy</function></funcdef>
+ <funcdef>boolean <function>ST_Touches</function></funcdef>
<paramdef>
<type>raster </type>
<parameter>rastA</parameter>
<title>Description</title>
<para>
- Raster rastA is covered by rastB if and only if no points of rastA lie in the exterior of rastB. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
+ Return true if raster rastA spatially touches raster rastB. This means that rastA and rastB have at least one point in common but their interiors do not intersect. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
</para>
<note>
<para>
- This operand will make use of any indexes that may be available on the rasters.
+ This function will make use of any indexes that may be available on the rasters.
</para>
</note>
<note>
<para>
- To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_CoveredBy(ST_Polygon(raster), geometry) or ST_CoveredBy(geometry, ST_Polygon(raster)).
+ To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Touches(ST_Polygon(raster), geometry).
</para>
</note>
<refsection>
<title>See Also</title>
<para>
- <xref linkend="RT_ST_Intersects" />,
- <xref linkend="RT_ST_Covers" />
+ <xref linkend="RT_ST_Intersects" />
</para>
</refsection>
</refentry>
CREATE OR REPLACE FUNCTION st_intersects(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
RETURNS boolean
- AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_intersects(st_convexhull($1), st_convexhull($3)) ELSE _st_intersects($1, $2, $3, $4) END $$
+ AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_intersects(st_convexhull($1), st_convexhull($3)) ELSE _st_intersects($1, $2, $3, $4) END $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
CREATE OR REPLACE FUNCTION st_overlaps(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
RETURNS boolean
- AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_overlaps(st_convexhull($1), st_convexhull($3)) ELSE _st_overlaps($1, $2, $3, $4) END $$
+ AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_overlaps(st_convexhull($1), st_convexhull($3)) ELSE _st_overlaps($1, $2, $3, $4) END $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
CREATE OR REPLACE FUNCTION st_touches(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
RETURNS boolean
- AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_touches(st_convexhull($1), st_convexhull($3)) ELSE _st_touches($1, $2, $3, $4) END $$
+ AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_touches(st_convexhull($1), st_convexhull($3)) ELSE _st_touches($1, $2, $3, $4) END $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
CREATE OR REPLACE FUNCTION st_contains(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
RETURNS boolean
- AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_contains(st_convexhull($1), st_convexhull($3)) ELSE _st_contains($1, $2, $3, $4) END $$
+ AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_contains(st_convexhull($1), st_convexhull($3)) ELSE _st_contains($1, $2, $3, $4) END $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
CREATE OR REPLACE FUNCTION st_containsproperly(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
RETURNS boolean
- AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_containsproperly(st_convexhull($1), st_convexhull($3)) ELSE _st_containsproperly($1, $2, $3, $4) END $$
+ AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_containsproperly(st_convexhull($1), st_convexhull($3)) ELSE _st_containsproperly($1, $2, $3, $4) END $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
CREATE OR REPLACE FUNCTION st_covers(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
RETURNS boolean
- AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_covers(st_convexhull($1), st_convexhull($3)) ELSE _st_covers($1, $2, $3, $4) END $$
+ AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_covers(st_convexhull($1), st_convexhull($3)) ELSE _st_covers($1, $2, $3, $4) END $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
CREATE OR REPLACE FUNCTION st_coveredby(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
RETURNS boolean
- AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_coveredby(st_convexhull($1), st_convexhull($3)) ELSE _st_coveredby($1, $2, $3, $4) END $$
+ AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_coveredby(st_convexhull($1), st_convexhull($3)) ELSE _st_coveredby($1, $2, $3, $4) END $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
CREATE OR REPLACE FUNCTION st_within(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
RETURNS boolean
- AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_within(st_convexhull($1), st_convexhull($3)) ELSE _st_contains($3, $4, $1, $2) END $$
+ AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_within(st_convexhull($1), st_convexhull($3)) ELSE _st_contains($3, $4, $1, $2) END $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
LANGUAGE 'sql' IMMUTABLE
COST 1000;
+-----------------------------------------------------------------------
+-- ST_Disjoint(raster, raster)
+-----------------------------------------------------------------------
+
+CREATE OR REPLACE FUNCTION st_disjoint(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
+ RETURNS boolean
+ AS $$ SELECT CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_disjoint(st_convexhull($1), st_convexhull($3)) ELSE NOT _st_intersects($1, $2, $3, $4) END $$
+ LANGUAGE 'sql' IMMUTABLE
+ COST 1000;
+
+CREATE OR REPLACE FUNCTION st_disjoint(rast1 raster, rast2 raster)
+ RETURNS boolean
+ AS $$ SELECT st_disjoint($1, NULL::integer, $2, NULL::integer) $$
+ LANGUAGE 'sql' IMMUTABLE
+ COST 1000;
+
-----------------------------------------------------------------------
-- ST_Intersection(geometry, raster) in geometry-space
-----------------------------------------------------------------------
--- /dev/null
+SET client_min_messages TO warning;
+
+DROP TABLE IF EXISTS raster_disjoint_rast;
+CREATE TABLE raster_disjoint_rast (
+ rid integer,
+ rast raster
+);
+CREATE OR REPLACE FUNCTION make_test_raster(rid integer, width integer DEFAULT 2, height integer DEFAULT 2, ul_x double precision DEFAULT 0, ul_y double precision DEFAULT 0, skew_x double precision DEFAULT 0, skew_y double precision DEFAULT 0)
+ RETURNS void
+ AS $$
+ DECLARE
+ x int;
+ y int;
+ rast raster;
+ BEGIN
+ rast := ST_MakeEmptyRaster(width, height, ul_x, ul_y, 1, 1, skew_x, skew_y, 0);
+ rast := ST_AddBand(rast, 1, '8BUI', 1, 0);
+
+
+ INSERT INTO raster_disjoint_rast VALUES (rid, rast);
+
+ RETURN;
+ END;
+ $$ LANGUAGE 'plpgsql';
+SELECT make_test_raster(0, 2, 2, -1, -1);
+SELECT make_test_raster(1, 2, 2);
+SELECT make_test_raster(2, 3, 3);
+DROP FUNCTION make_test_raster(integer, integer, integer, double precision, double precision, double precision, double precision);
+
+INSERT INTO raster_disjoint_rast VALUES (10, (
+ SELECT
+ ST_SetValue(rast, 1, 1, 1, 0)
+ FROM raster_disjoint_rast
+ WHERE rid = 1
+));
+INSERT INTO raster_disjoint_rast VALUES (11, (
+ SELECT
+ ST_SetValue(rast, 1, 2, 1, 0)
+ FROM raster_disjoint_rast
+ WHERE rid = 1
+));
+INSERT INTO raster_disjoint_rast VALUES (12, (
+ SELECT
+ ST_SetValue(
+ ST_SetValue(
+ ST_SetValue(rast, 1, 1, 1, 0),
+ 1, 2, 1, 0
+ ),
+ 1, 1, 2, 0
+ )
+ FROM raster_disjoint_rast
+ WHERE rid = 1
+));
+INSERT INTO raster_disjoint_rast VALUES (13, (
+ SELECT
+ ST_SetValue(
+ ST_SetValue(
+ ST_SetValue(
+ ST_SetValue(rast, 1, 1, 1, 0),
+ 1, 2, 1, 0
+ ),
+ 1, 1, 2, 0
+ ),
+ 1, 2, 2, 0
+ )
+ FROM raster_disjoint_rast
+ WHERE rid = 1
+));
+INSERT INTO raster_disjoint_rast VALUES (14, (
+ SELECT
+ ST_SetUpperLeft(rast, 2, 0)
+ FROM raster_disjoint_rast
+ WHERE rid = 1
+));
+INSERT INTO raster_disjoint_rast VALUES (15, (
+ SELECT
+ ST_SetScale(
+ ST_SetUpperLeft(rast, 0.1, 0.1),
+ 0.4, 0.4
+ )
+ FROM raster_disjoint_rast
+ WHERE rid = 1
+));
+INSERT INTO raster_disjoint_rast VALUES (16, (
+ SELECT
+ ST_SetScale(
+ ST_SetUpperLeft(rast, -0.1, 0.1),
+ 0.4, 0.4
+ )
+ FROM raster_disjoint_rast
+ WHERE rid = 1
+));
+
+INSERT INTO raster_disjoint_rast VALUES (20, (
+ SELECT
+ ST_SetUpperLeft(rast, -2, -2)
+ FROM raster_disjoint_rast
+ WHERE rid = 2
+));
+INSERT INTO raster_disjoint_rast VALUES (21, (
+ SELECT
+ ST_SetValue(
+ ST_SetValue(
+ ST_SetValue(rast, 1, 1, 1, 0),
+ 1, 2, 2, 0
+ ),
+ 1, 3, 3, 0
+ )
+ FROM raster_disjoint_rast
+ WHERE rid = 20
+));
+INSERT INTO raster_disjoint_rast VALUES (22, (
+ SELECT
+ ST_SetValue(
+ ST_SetValue(
+ rast, 1, 3, 2, 0
+ ),
+ 1, 2, 3, 0
+ )
+ FROM raster_disjoint_rast
+ WHERE rid = 21
+));
+INSERT INTO raster_disjoint_rast VALUES (23, (
+ SELECT
+ ST_SetValue(
+ ST_SetValue(
+ rast, 1, 3, 1, 0
+ ),
+ 1, 1, 3, 0
+ )
+ FROM raster_disjoint_rast
+ WHERE rid = 22
+));
+
+INSERT INTO raster_disjoint_rast VALUES (30, (
+ SELECT
+ ST_SetSkew(rast, -0.5, 0.5)
+ FROM raster_disjoint_rast
+ WHERE rid = 2
+));
+INSERT INTO raster_disjoint_rast VALUES (31, (
+ SELECT
+ ST_SetSkew(rast, -1, 1)
+ FROM raster_disjoint_rast
+ WHERE rid = 2
+));
+INSERT INTO raster_disjoint_rast VALUES (32, (
+ SELECT
+ ST_SetSkew(rast, 1, -1)
+ FROM raster_disjoint_rast
+ WHERE rid = 2
+));
+
+SELECT
+ '1.1',
+ r1.rid,
+ r2.rid,
+ ST_Disjoint(r1.rast, NULL, r2.rast, NULL)
+FROM raster_disjoint_rast r1
+JOIN raster_disjoint_rast r2
+ ON r1.rid != r2.rid
+WHERE r1.rid = 0;
+
+SELECT
+ '1.2',
+ r1.rid,
+ r2.rid,
+ ST_Disjoint(r1.rast, 1, r2.rast, 1)
+FROM raster_disjoint_rast r1
+JOIN raster_disjoint_rast r2
+ ON r1.rid != r2.rid
+WHERE r1.rid = 0;
+
+DROP TABLE IF EXISTS raster_disjoint_rast;