mirror of
https://git.osgeo.org/gitea/postgis/postgis
synced 2024-10-25 09:32:46 +00:00
2abafcc80d
git-svn-id: http://svn.osgeo.org/postgis/trunk@6068 b70326c6-7e19-0410-871a-916f4a2858ee
3045 lines
100 KiB
XML
3045 lines
100 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<chapter id="RT_reference">
|
|
<title>Raster Reference</title>
|
|
|
|
<para>The functions given below are the ones which a user of PostGIS Raster is
|
|
likely to need and which are currently available in PostGIS Raster. There are other functions which are required support
|
|
functions to the raster objects which are not of use to a general
|
|
user.</para>
|
|
<para><varname>raster</varname> is a new PostGIS type for storing and analyzing raster data. </para>
|
|
<para>For more information about Raster, please refer to <ulink url="http://trac.osgeo.org/postgis/wiki/WKTRaster">PostGIS Raster Home Page</ulink>.</para>
|
|
<para>For the examples in this reference we will be using a raster table of dummy rasters - Formed with the following code </para>
|
|
<programlisting>
|
|
CREATE TABLE dummy_rast(rid integer, rast raster);
|
|
INSERT INTO dummy_rast(rid, rast)
|
|
VALUES (1,
|
|
('01' -- little endian (uint8 ndr)
|
|
||
|
|
'0000' -- version (uint16 0)
|
|
||
|
|
'0000' -- nBands (uint16 0)
|
|
||
|
|
'0000000000000040' -- scaleX (float64 2)
|
|
||
|
|
'0000000000000840' -- scaleY (float64 3)
|
|
||
|
|
'000000000000E03F' -- ipX (float64 0.5)
|
|
||
|
|
'000000000000E03F' -- ipY (float64 0.5)
|
|
||
|
|
'0000000000000000' -- skewX (float64 0)
|
|
||
|
|
'0000000000000000' -- skewY (float64 0)
|
|
||
|
|
'00000000' -- SRID (int32 0)
|
|
||
|
|
'0A00' -- width (uint16 10)
|
|
||
|
|
'1400' -- height (uint16 20)
|
|
)::raster
|
|
),
|
|
-- Raster: 5 x 5 pixels, 3 bands, PT_8BUI pixel type, NODATA = 0
|
|
(2, ('01000003009A9999999999A93F9A9999999999A9BF000000E02B274A' ||
|
|
'41000000007719564100000000000000000000000000000000FFFFFFFF050005000400FDFEFDFEFEFDFEFEFDF9FAFEF' ||
|
|
'EFCF9FBFDFEFEFDFCFAFEFEFE04004E627AADD16076B4F9FE6370A9F5FE59637AB0E54F58617087040046566487A1506CA2E3FA5A6CAFFBFE4D566DA4CB3E454C5665')::raster);
|
|
</programlisting>
|
|
<sect1 id="Raster_Management_Functions">
|
|
<title>Raster Management Functions</title>
|
|
<refentry id="RT_AddRasterColumn">
|
|
<refnamediv>
|
|
<refname>AddRasterColumn</refname>
|
|
|
|
<refpurpose>Adds a raster column to an existing table and generates column constraint on the new column to enforce srid.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>text <function>AddRasterColumn</function></funcdef>
|
|
|
|
<paramdef><type>varchar </type>
|
|
<parameter>table_name</parameter></paramdef>
|
|
|
|
<paramdef><type>varchar </type>
|
|
<parameter>column_name</parameter></paramdef>
|
|
|
|
<paramdef><type>integer </type>
|
|
<parameter>srid</parameter></paramdef>
|
|
|
|
<paramdef><type>varchar[] </type>
|
|
<parameter>pixel_types</parameter></paramdef>
|
|
|
|
<paramdef><type>boolean </type>
|
|
<parameter>out_db</parameter></paramdef>
|
|
|
|
<paramdef><type>boolean </type>
|
|
<parameter>regular_blocking</parameter></paramdef>
|
|
|
|
<paramdef><type>double precision[] </type>
|
|
<parameter>no_data_values</parameter></paramdef>
|
|
|
|
<paramdef><type>double precision </type>
|
|
<parameter>pixelsize_x</parameter></paramdef>
|
|
|
|
<paramdef><type>double precision </type>
|
|
<parameter>pixelsize_y</parameter></paramdef>
|
|
|
|
<paramdef><type>integer </type>
|
|
<parameter>blocksize_x</parameter></paramdef>
|
|
|
|
<paramdef><type>integer </type>
|
|
<parameter>blocksize_y</parameter></paramdef>
|
|
|
|
<paramdef><type>geometry </type>
|
|
<parameter>envelope</parameter></paramdef>
|
|
</funcprototype>
|
|
|
|
<funcprototype>
|
|
<funcdef>text <function>AddRasterColumn</function></funcdef>
|
|
<paramdef><type>varchar </type>
|
|
<parameter>schema_name</parameter></paramdef>
|
|
|
|
<paramdef><type>varchar </type>
|
|
<parameter>table_name</parameter></paramdef>
|
|
|
|
<paramdef><type>varchar </type>
|
|
<parameter>column_name</parameter></paramdef>
|
|
|
|
<paramdef><type>integer </type>
|
|
<parameter>srid</parameter></paramdef>
|
|
|
|
<paramdef><type>varchar[] </type>
|
|
<parameter>pixel_types</parameter></paramdef>
|
|
|
|
<paramdef><type>boolean </type>
|
|
<parameter>out_db</parameter></paramdef>
|
|
|
|
<paramdef><type>boolean </type>
|
|
<parameter>regular_blocking</parameter></paramdef>
|
|
|
|
<paramdef><type>double precision[] </type>
|
|
<parameter>no_data_values</parameter></paramdef>
|
|
|
|
<paramdef><type>double precision </type>
|
|
<parameter>pixelsize_x</parameter></paramdef>
|
|
|
|
<paramdef><type>double precision </type>
|
|
<parameter>pixelsize_y</parameter></paramdef>
|
|
|
|
<paramdef><type>integer </type>
|
|
<parameter>blocksize_x</parameter></paramdef>
|
|
|
|
<paramdef><type>integer </type>
|
|
<parameter>blocksize_y</parameter></paramdef>
|
|
|
|
<paramdef><type>geometry </type>
|
|
<parameter>envelope</parameter></paramdef>
|
|
</funcprototype>
|
|
|
|
<funcprototype>
|
|
<funcdef>text <function>AddRasterColumn</function></funcdef>
|
|
|
|
<paramdef><type>varchar </type>
|
|
<parameter>catalog_name</parameter></paramdef>
|
|
|
|
<paramdef><type>varchar </type>
|
|
<parameter>schema_name</parameter></paramdef>
|
|
|
|
<paramdef><type>varchar </type>
|
|
<parameter>table_name</parameter></paramdef>
|
|
|
|
<paramdef><type>varchar </type>
|
|
<parameter>column_name</parameter></paramdef>
|
|
|
|
<paramdef><type>integer </type>
|
|
<parameter>srid</parameter></paramdef>
|
|
|
|
<paramdef><type>varchar[] </type>
|
|
<parameter>pixel_types</parameter></paramdef>
|
|
|
|
<paramdef><type>boolean </type>
|
|
<parameter>out_db</parameter></paramdef>
|
|
|
|
<paramdef><type>boolean </type>
|
|
<parameter>regular_blocking</parameter></paramdef>
|
|
|
|
<paramdef><type>double precision[] </type>
|
|
<parameter>no_data_values</parameter></paramdef>
|
|
|
|
<paramdef><type>double precision </type>
|
|
<parameter>pixelsize_x</parameter></paramdef>
|
|
|
|
<paramdef><type>double precision </type>
|
|
<parameter>pixelsize_y</parameter></paramdef>
|
|
|
|
<paramdef><type>integer </type>
|
|
<parameter>blocksize_x</parameter></paramdef>
|
|
|
|
<paramdef><type>integer </type>
|
|
<parameter>blocksize_y</parameter></paramdef>
|
|
|
|
<paramdef><type>geometry </type>
|
|
<parameter>envelope</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Adds a raster column to an existing table and also generates constraints on the new column. Currently only constrains the <varname>SRID</varname>.
|
|
The <varname>schema_name</varname> is the name of the table schema (unused
|
|
for pre-schema PostgreSQL installations). The <varname>srid</varname>
|
|
must be an integer value reference to an entry in the SPATIAL_REF_SYS
|
|
table. The <varname>pixel_types</varname> must be an array of pixel types as described in <xref linkend="RT_ST_BandPixelType" />, one for each band.
|
|
An error is thrown if the schemaname doesn't exist
|
|
(or not visible in the current search_path) or the specified SRID,
|
|
pixel types are invalid.</para>
|
|
|
|
<para><varname>gdal2raster.py</varname> loader uses this function to register raster tables</para>
|
|
|
|
<note>
|
|
<para>Views and derivatively created spatial tables will need to be registered in raster_columns manually,
|
|
since AddRasterColumn also adds a raster column which is not needed when you already have a raster column.
|
|
</para>
|
|
</note>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT AddRasterColumn('public', 'myrasters', 'rast',4326,
|
|
'{8BUI,8BUI,8BUI,8BUI}',
|
|
false, true, '{255,255,255,255}', 0.25,-0.25,200,300, null);
|
|
|
|
public.myrasters.rast
|
|
srid:4326 pixel_types:{8BUI,8BUI,8BUI,8BUI}
|
|
out_db:false
|
|
regular_blocking:true
|
|
nodata_values:'{255,255,255,255}'
|
|
pixelsize_x:'0.25'
|
|
pixelsize_y:'-0.25' blocksize_x:'200' blocksize_y:'300' extent:NULL
|
|
|
|
--- After loading the data, you can currect the geometry column
|
|
UPDATE raster_columns SET extent = (SELECT ST_Union(ST_Envelope(rast)) FROM myrasters)
|
|
WHERE r_table_schema = 'public'
|
|
AND r_table_name = 'myrasters'
|
|
AND r_column = 'rast';
|
|
</programlisting>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
|
|
<para><xref linkend="AddGeometryColumn"/>, <xref linkend="RT_DropRasterTable"/>, <xref linkend="RT_DropRasterColumn"/>, <xref linkend="RT_ST_SRID" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_DropRasterColumn">
|
|
<refnamediv>
|
|
<refname>DropRasterColumn</refname>
|
|
|
|
<refpurpose>Removes a raster column from a table.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>text <function>DropRasterColumn</function></funcdef>
|
|
|
|
<paramdef><type>varchar </type>
|
|
<parameter>table_name</parameter></paramdef>
|
|
|
|
<paramdef><type>varchar </type>
|
|
<parameter>column_name</parameter></paramdef>
|
|
</funcprototype>
|
|
|
|
<funcprototype>
|
|
<funcdef>text <function>DropRasterColumn</function></funcdef>
|
|
|
|
<paramdef><type>varchar </type>
|
|
<parameter>schema_name</parameter></paramdef>
|
|
|
|
<paramdef><type>varchar </type>
|
|
<parameter>table_name</parameter></paramdef>
|
|
|
|
<paramdef><type>varchar </type>
|
|
<parameter>column_name</parameter></paramdef>
|
|
</funcprototype>
|
|
|
|
<funcprototype>
|
|
<funcdef>text <function>DropRasterColumn</function></funcdef>
|
|
|
|
<paramdef><type>varchar </type>
|
|
<parameter>catalog_name</parameter></paramdef>
|
|
|
|
<paramdef><type>varchar </type>
|
|
<parameter>schema_name</parameter></paramdef>
|
|
|
|
<paramdef><type>varchar </type>
|
|
<parameter>table_name</parameter></paramdef>
|
|
|
|
<paramdef><type>varchar </type>
|
|
<parameter>column_name</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Removes a raster column from a table. Note that
|
|
schema_name will need to match the r_table_schema field of the table's
|
|
row in the raster_columns table.</para>
|
|
</refsection>
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>
|
|
SELECT DropRasterColumn ('my_schema','my_raster_table','rast');
|
|
----RESULT output ---
|
|
my_schema.my_raster_table.rast effectively removed.
|
|
</programlisting>
|
|
</refsection>
|
|
<refsection>
|
|
<title>See Also</title>
|
|
|
|
<para><xref linkend="RT_AddRasterColumn"/>, <xref linkend="RT_DropRasterTable"/></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_DropRasterTable">
|
|
<refnamediv>
|
|
<refname>DropRasterTable</refname>
|
|
|
|
<refpurpose>Drops a table and all its references in
|
|
raster_columns.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>text <function>DropRasterTable</function></funcdef>
|
|
|
|
<paramdef><type>varchar </type>
|
|
<parameter>table_name</parameter></paramdef>
|
|
</funcprototype>
|
|
|
|
<funcprototype>
|
|
<funcdef>text <function>DropRasterTable</function></funcdef>
|
|
|
|
<paramdef><type>varchar </type>
|
|
<parameter>schema_name</parameter></paramdef>
|
|
|
|
<paramdef><type>varchar </type>
|
|
<parameter>table_name</parameter></paramdef>
|
|
</funcprototype>
|
|
|
|
<funcprototype>
|
|
<funcdef>text <function>DropRasterTable</function></funcdef>
|
|
<paramdef><type>varchar </type>
|
|
<parameter>catalog_name</parameter></paramdef>
|
|
<paramdef><type>varchar </type>
|
|
<parameter>schema_name</parameter></paramdef>
|
|
<paramdef><type>varchar </type>
|
|
<parameter>table_name</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Drops a table and all its references in raster_columns. Note:
|
|
uses current_schema() on schema-aware pgsql installations if schema is
|
|
not provided.</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>
|
|
SELECT DropRasterTable ('my_schema','my_raster_table');
|
|
----RESULT output ---
|
|
my_schema.my_raster_table dropped.
|
|
</programlisting>
|
|
</refsection>
|
|
<refsection>
|
|
<title>See Also</title>
|
|
|
|
<para><xref linkend="RT_AddRasterColumn"/>, <xref linkend="RT_DropRasterColumn"/></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_PostGIS_Raster_Lib_Build_Date()">
|
|
<refnamediv>
|
|
<refname>PostGIS_Raster_Lib_Build_Date</refname>
|
|
|
|
<refpurpose>Reports full raster library build date</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>text <function>PostGIS_Raster_Lib_Build_Date</function></funcdef>
|
|
|
|
<paramdef></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Reports raster build date</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT PostGIS_Raster_Lib_Build_Date();
|
|
postgis_raster_lib_build_date
|
|
-----------------------------
|
|
2010-04-28 21:15:10
|
|
</programlisting>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
|
|
<para> <xref linkend="RT_PostGIS_Raster_Lib_Version" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_PostGIS_Raster_Lib_Version">
|
|
<refnamediv>
|
|
<refname>PostGIS_Raster_Lib_Version</refname>
|
|
|
|
<refpurpose>Reports full raster version and build configuration
|
|
infos.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>text <function>PostGIS_Raster_Lib_Version</function></funcdef>
|
|
|
|
<paramdef></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Reports full raster version and build configuration
|
|
infos.</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT PostGIS_Raster_Lib_Version();
|
|
postgis_raster_lib_version
|
|
-----------------------------
|
|
0.1.6d
|
|
</programlisting>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
|
|
<para> <xref
|
|
linkend="PostGIS_Lib_Version" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
</sect1>
|
|
|
|
<sect1 id="Raster_Constructors">
|
|
<title>Raster Constructors</title>
|
|
<refentry id="RT_ST_MakeEmptyRaster">
|
|
<refnamediv>
|
|
<refname>ST_MakeEmptyRaster</refname>
|
|
<refpurpose>Returns an empty raster of given dimensions, pixel x y, skew and spatial reference system with no bands</refpurpose>
|
|
</refnamediv>
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>raster <function>ST_MakeEmptyRaster</function></funcdef>
|
|
<paramdef><type>integer </type> <parameter>width</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>height</parameter></paramdef>
|
|
<paramdef><type>float8 </type> <parameter>ipx</parameter></paramdef>
|
|
<paramdef><type>float8 </type> <parameter>ipy</parameter></paramdef>
|
|
<paramdef><type>float8 </type> <parameter>scalex</parameter></paramdef>
|
|
<paramdef><type>float8 </type> <parameter>scaley</parameter></paramdef>
|
|
<paramdef><type>float8 </type> <parameter>skewx</parameter></paramdef>
|
|
<paramdef><type>float8 </type> <parameter>skewy</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>srid</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns an empty raster of given dimensions, pixel x y, skew and spatial reference system with no bands</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>
|
|
INSERT INTO dummy_rast(rid,rast)
|
|
VALUES(3, ST_MakeEmptyRaster( 100, 100, 0.0005, 0.0005, 1, 1, 0, 0, 4326) )
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para></para>
|
|
</refsection>
|
|
</refentry>
|
|
</sect1>
|
|
<sect1 id="Raster_Accessors">
|
|
<title>Raster Accessors</title>
|
|
<refentry id="RT_ST_GeoReference">
|
|
<refnamediv>
|
|
<refname>ST_GeoReference</refname>
|
|
<refpurpose>Returns the georeference meta data in GDAL or ESRI format as commonly seen in a world file. Default is GDAL.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_GeoReference</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_GeoReference</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>text </type> <parameter>format</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the georeference meta data including carriage return in GDAL or ESRI format as commonly seen in a <ulink href="http://en.wikipedia.org/wiki/World_file">world file</ulink>. Default is GDAL if no type specified. type is string 'GDAL' or 'ESRI'.
|
|
</para>
|
|
<para>Difference between format representations is as follows:</para>
|
|
<para><varname>GDAL</varname>:
|
|
<programlisting>pixelsizex
|
|
skewy
|
|
skewx
|
|
pixelsizey
|
|
upperleftx
|
|
upperlefty</programlisting></para>
|
|
<para><varname>ESRI</varname>:
|
|
<programlisting>pixelsizex
|
|
skewy
|
|
skewx
|
|
pixelsizey
|
|
upperleftx + pixelsizex*0.5
|
|
upperlefty + pixelsizey*0.5</programlisting></para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT ST_GeoReference(rast, 'ESRI') As esri_ref, ST_GeoReference(rast, 'GDAL') As gdal_ref
|
|
FROM dummy_rast WHERE rid=1;
|
|
|
|
esri_ref | gdal_ref
|
|
--------------+--------------
|
|
2.0000000000 | 2.0000000000
|
|
0.0000000000 : 0.0000000000
|
|
0.0000000000 : 0.0000000000
|
|
3.0000000000 : 3.0000000000
|
|
1.5000000000 : 0.5000000000
|
|
2.0000000000 : 0.5000000000
|
|
</programlisting>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_SetGeoReference" />, <xref linkend="RT_ST_PixelSizeX" />, <xref linkend="RT_ST_PixelSizeY" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_Height">
|
|
<refnamediv>
|
|
<refname>ST_Height</refname>
|
|
<refpurpose>Returns the height of the raster in pixels?</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>integer <function>ST_Height</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the height of the raster.</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT rid, ST_Height(rast) As rastheight
|
|
FROM dummy_rast;
|
|
|
|
rid | rastheight
|
|
-----+------------
|
|
1 | 20
|
|
2 | 5
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_Width" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_MetaData">
|
|
<refnamediv>
|
|
<refname>ST_MetaData</refname>
|
|
<refpurpose>Returns basic meta data about a raster object such as skew, rotation, upper,lower left etc.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>record <function>ST_MetaData</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns basic meta data about a raster object such as skew, rotation, upper,lower left etc. Columns returned
|
|
upperleftx | upperlefty | width | height | pixelsizex | pixelsizey | skewx | skewy | srid | numbands</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT rid, (foo.md).*
|
|
FROM (SELECT rid, ST_MetaData(rast) As md
|
|
FROM dummy_rast) As foo;
|
|
|
|
rid | upperleftx | upperlefty | width | height | pixelsizex | pixelsizey | skewx | skewy | srid | numbands
|
|
-----+------------+------------+-------+--------+-----------+-----------+-------+-------+------+----------
|
|
1 | 0.5 | 0.5 | 10 | 20 | 2 | 3 | 0 | 0 | 0 | 0
|
|
2 | 3427927.75 | 5793244 | 5 | 5 | 0.05 | -0.05 | 0 | 0 | -1 | 3
|
|
</programlisting>
|
|
</refsection>
|
|
|
|
<!-- Optionally add a "See Also" section -->
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_BandMetaData" />, <xref linkend="RT_ST_NumBands" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_NumBands">
|
|
<refnamediv>
|
|
<refname>ST_NumBands</refname>
|
|
<refpurpose>Returns the number of bands in the raster object.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>integer <function>ST_NumBands</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the number of bands in the raster object.</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT rid, ST_NumBands(rast) As numbands
|
|
FROM dummy_rast;
|
|
|
|
rid | numbands
|
|
----+----------
|
|
1 | 0
|
|
2 | 3
|
|
</programlisting>
|
|
</refsection>
|
|
|
|
<!-- Optionally add a "See Also" section -->
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_Value" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_PixelSizeX">
|
|
<refnamediv>
|
|
<refname>ST_PixelSizeX</refname>
|
|
<refpurpose>Returns the x size of pixels in units of coordinate reference system?</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>float8 <function>ST_PixelSizeX</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the x size of pixels in units of coordinate reference system?</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT rid, ST_PixelSizeX(rast) As rastpixwidth
|
|
FROM dummy_rast;
|
|
|
|
rid | rastpixwidth
|
|
-----+--------------
|
|
1 | 2
|
|
2 | 0.05
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<!-- Optionally add a "See Also" section -->
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_Width" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_PixelSizeY">
|
|
<refnamediv>
|
|
<refname>ST_PixelSizeY</refname>
|
|
<refpurpose>Returns the y size of pixels in units of coordinate reference system?</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>float8 <function>ST_PixelSizeY</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the y size of pixels in units of coordinate reference system. May be negative. Refer to <ulink url="http://en.wikipedia.org/wiki/World_file">World File</ulink>
|
|
for more details.</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT rid, ST_PixelSizeY(rast) As rastpixheight
|
|
FROM dummy_rast;
|
|
|
|
rid | rastpixheight
|
|
-----+---------------
|
|
1 | 3
|
|
2 | -0.05
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<!-- Optionally add a "See Also" section -->
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_Height" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_Raster2WorldCoordX">
|
|
<refnamediv>
|
|
<refname>ST_Raster2WorldCoordX</refname>
|
|
<refpurpose>Returns the geometric x coordinate upper left of a raster , column and row. Numbering of columns
|
|
and rows starts at 1. </refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>float8 <function>ST_Raster2WorldCoordX</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>xcolumn</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>float8 <function>ST_Raster2WorldCoordX</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>xcolumn</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>yrow</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the upper left x coordinate of a raster column row in geometric units of the georeferenced raster.
|
|
Numbering of columns and rows starts at 1 but if you pass in a negative number or number higher than number of
|
|
columns in raster, it will give you
|
|
coordinates outside of the raster file to left or right with the assumption that the
|
|
skew and pixel sizes are same as selected raster. </para>
|
|
<para><note>For non-skewed rasters, providing the x column is sufficient. For skewed rasters,
|
|
the georeferenced coordinate is a function of the ST_PixelSizeX and SkewX and row and column.
|
|
An error will be raised if you give just the x column for a skewed raster.</note></para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>
|
|
-- non-skewed raster providing column is sufficient
|
|
SELECT rid, ST_Raster2WorldCoordX(rast,1) As x1coord,
|
|
ST_Raster2WorldCoordX(rast,2) As x2coord,
|
|
ST_PixelSizeX(rast) As pixelx
|
|
FROM dummy_rast;
|
|
|
|
rid | x1coord | x2coord | pixelx
|
|
-----+------------+-----------+--------
|
|
1 | 0.5 | 2.5 | 2
|
|
2 | 3427927.75 | 3427927.8 | 0.05
|
|
</programlisting>
|
|
|
|
<programlisting>
|
|
-- for fun lets skew it
|
|
SELECT rid, ST_Raster2WorldCoordX(rast,1,1) As x1coord,
|
|
ST_Raster2WorldCoordX(rast,2,3) As x2coord,
|
|
ST_PixelSizeX(rast) As pixelx
|
|
FROM (SELECT rid, ST_SetSkew(rast,100.5,0) As rast FROM dummy_rast) As foo;
|
|
|
|
rid | x1coord | x2coord | pixelx
|
|
-----+------------+-----------+--------
|
|
1 | 0.5 | 203.5 | 2
|
|
2 | 3427927.75 | 3428128.8 | 0.05
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<!-- Optionally add a "See Also" section -->
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_PixelSizeX" />, <xref linkend="RT_ST_Raster2WorldCoordY" />, <xref linkend="RT_ST_SetSkew" />, <xref linkend="RT_ST_SkewX" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_Raster2WorldCoordY">
|
|
<refnamediv>
|
|
<refname>ST_Raster2WorldCoordY</refname>
|
|
<refpurpose>Returns the geometric y coordinate upper left corner of a raster , column and row. Numbering of columns
|
|
and rows starts at 1. </refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>float8 <function>ST_Raster2WorldCoordY</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>yrow</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>float8 <function>ST_Raster2WorldCoordY</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>xcolumn</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>yrow</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the upper left y coordinate of a raster column row in geometric units of the georeferenced raster.
|
|
Numbering of columns and rows starts at 1 but if you pass in a negative number or number higher than number of
|
|
columns/rows in raster, it will give you
|
|
coordinates outside of the raster file to left or right with the assumption that the
|
|
skew and pixel sizes are same as selected raster tile. </para>
|
|
<para><note>For non-skewed rasters, providing the y column is sufficient. For skewed rasters,
|
|
the georeferenced coordinate is a function of the ST_PixelSizeY and SkewY and row and column.
|
|
An error will be raised if you give just the y row for a skewed raster.</note></para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>
|
|
-- non-skewed raster providing row is sufficient
|
|
SELECT rid, ST_Raster2WorldCoordY(rast,1) As y1coord,
|
|
ST_Raster2WorldCoordY(rast,3) As y2coord,
|
|
ST_PixelSizeY(rast) As pixely
|
|
FROM dummy_rast;
|
|
|
|
rid | y1coord | y2coord | pixely
|
|
-----+---------+-----------+--------
|
|
1 | 0.5 | 6.5 | 3
|
|
2 | 5793244 | 5793243.9 | -0.05
|
|
</programlisting>
|
|
|
|
<programlisting>
|
|
-- for fun lets skew it
|
|
SELECT rid, ST_Raster2WorldCoordY(rast,1,1) As y1coord,
|
|
ST_Raster2WorldCoordY(rast,2,3) As y2coord,
|
|
ST_PixelSizeY(rast) As pixely
|
|
FROM (SELECT rid, ST_SetSkew(rast,0,100.5) As rast FROM dummy_rast) As foo;
|
|
|
|
rid | y1coord | y2coord | pixely
|
|
-----+---------+-----------+--------
|
|
1 | 0.5 | 107 | 3
|
|
2 | 5793244 | 5793344.4 | -0.05
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<!-- Optionally add a "See Also" section -->
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_PixelSizeY" />, <xref linkend="RT_ST_Raster2WorldCoordX" />, <xref linkend="RT_ST_SetSkew" />, <xref linkend="RT_ST_SkewY" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_SkewX">
|
|
<refnamediv>
|
|
<refname>ST_SkewX</refname>
|
|
<refpurpose>Returns the georeference X skew (or rotation parameter)</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>float8 <function>ST_SkewX</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the georeference X skew (or rotation parameter). Refer to <ulink url="http://en.wikipedia.org/wiki/World_file">World File</ulink>
|
|
for more details.</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT rid, ST_SkewX(rast) As skewx, ST_SkewY(rast) As skewy,
|
|
ST_GeoReference(rast) as georef
|
|
FROM dummy_rast;
|
|
|
|
rid | skewx | skewy | georef
|
|
-----+-------+-------+--------------------
|
|
1 | 0 | 0 | 2.0000000000
|
|
: 0.0000000000
|
|
: 0.0000000000
|
|
: 3.0000000000
|
|
: 0.5000000000
|
|
: 0.5000000000
|
|
:
|
|
2 | 0 | 0 | 0.0500000000
|
|
: 0.0000000000
|
|
: 0.0000000000
|
|
: -0.0500000000
|
|
: 3427927.7500000000
|
|
: 5793244.0000000000
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<!-- Optionally add a "See Also" section -->
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_GeoReference" />, <xref linkend="RT_ST_SkewY" />, <xref linkend="RT_ST_SetSkew" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_SkewY">
|
|
<refnamediv>
|
|
<refname>ST_SkewY</refname>
|
|
<refpurpose>Returns the georeference Y skew (or rotation parameter)</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>float8 <function>ST_SkewY</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the georeference Y skew (or rotation parameter). Refer to <ulink url="http://en.wikipedia.org/wiki/World_file">World File</ulink>
|
|
for more details.</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT rid, ST_SkewX(rast) As skewx, ST_SkewY(rast) As skewy,
|
|
ST_GeoReference(rast) as georef
|
|
FROM dummy_rast;
|
|
|
|
rid | skewx | skewy | georef
|
|
-----+-------+-------+--------------------
|
|
1 | 0 | 0 | 2.0000000000
|
|
: 0.0000000000
|
|
: 0.0000000000
|
|
: 3.0000000000
|
|
: 0.5000000000
|
|
: 0.5000000000
|
|
:
|
|
2 | 0 | 0 | 0.0500000000
|
|
: 0.0000000000
|
|
: 0.0000000000
|
|
: -0.0500000000
|
|
: 3427927.7500000000
|
|
: 5793244.0000000000
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<!-- Optionally add a "See Also" section -->
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_GeoReference" />, <xref linkend="RT_ST_SkewX" />, <xref linkend="RT_ST_SetSkew" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_SRID">
|
|
<refnamediv>
|
|
<refname>ST_SRID</refname>
|
|
<refpurpose>Returns the spatial reference identifier of the raster as defined in spatial_ref_sys table.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>integer <function>ST_SRID</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the spatial reference identifier of the raster object as defined in the spatial_ref_sys table.</para>
|
|
<note><para>From PostGIS 2.0+ the srid of a non-georeferenced raster/geometry is 0 instead of the prior -1.</para></note>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT ST_SRID(rast) As srid
|
|
FROM dummy_rast WHERE rid=1;
|
|
|
|
srid
|
|
----------------
|
|
0
|
|
</programlisting>
|
|
</refsection>
|
|
|
|
<!-- Optionally add a "See Also" section -->
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="spatial_ref_sys" />, <xref linkend="ST_SRID" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_UpperLeftX">
|
|
<refnamediv>
|
|
<refname>ST_UpperLeftX</refname>
|
|
<refpurpose>Returns the upper left x coordinate of raster in projected spatial ref.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>float8 <function>ST_UpperLeftX</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the upper left x coordinate of raster in projected spatial ref.</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>
|
|
SELECt rid, ST_UpperLeftX(rast) As ulx
|
|
FROM dummy_rast;
|
|
|
|
rid | ulx
|
|
-----+------------
|
|
1 | 0.5
|
|
2 | 3427927.75
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_UpperLeftY" />, <xref linkend="RT_ST_GeoReference" />, <xref linkend="RT_ST_Box2D" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_UpperLeftY">
|
|
<refnamediv>
|
|
<refname>ST_UpperLeftY</refname>
|
|
<refpurpose>Returns the upper left y coordinate of raster in projected spatial ref.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>float8 <function>ST_UpperLeftY</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the upper left y coordinate of raster in projected spatial ref.</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>
|
|
SELECT rid, ST_UpperLeftY(rast) As uly
|
|
FROM dummy_rast;
|
|
|
|
rid | uly
|
|
-----+---------
|
|
1 | 0.5
|
|
2 | 5793244
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_UpperLeftX" />, <xref linkend="RT_ST_GeoReference" />, <xref linkend="RT_ST_Box2D" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="RT_ST_Width">
|
|
<refnamediv>
|
|
<refname>ST_Width</refname>
|
|
<refpurpose>Returns the width of the raster in pixels?</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>integer <function>ST_Width</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the width of the raster.</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT ST_Width(rast) As rastwidth
|
|
FROM dummy_rast WHERE rid=1;
|
|
|
|
rastwidth
|
|
----------------
|
|
10
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<!-- Optionally add a "See Also" section -->
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_Height" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
</sect1>
|
|
|
|
<sect1 id="RasterBand_Accessors">
|
|
<title>Raster Band Accessors and Contructors</title>
|
|
<refentry id="RT_ST_AddBand">
|
|
<refnamediv>
|
|
<refname>ST_AddBand</refname>
|
|
<refpurpose>Returns a raster with the new band of given type added with given initial value</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>raster <function>ST_AddBand</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>text </type> <parameter>pixeltype</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>raster <function>ST_AddBand</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>text </type> <parameter>pixeltype</parameter></paramdef>
|
|
<paramdef><type>double precision </type> <parameter>initialvalue</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>raster <function>ST_AddBand</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>text </type> <parameter>pixeltype</parameter></paramdef>
|
|
<paramdef><type>double precision </type> <parameter>initialvalue</parameter></paramdef>
|
|
<paramdef><type>double precision </type> <parameter>nodataval</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>raster <function>ST_AddBand</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>index</parameter></paramdef>
|
|
<paramdef><type>text </type> <parameter>pixeltype</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>raster <function>ST_AddBand</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>band_num</parameter></paramdef>
|
|
<paramdef><type>text </type> <parameter>pixeltype</parameter></paramdef>
|
|
<paramdef><type>double precision </type> <parameter>initialvalue</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>raster <function>ST_AddBand</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>band_num</parameter></paramdef>
|
|
<paramdef><type>text </type> <parameter>pixeltype</parameter></paramdef>
|
|
<paramdef><type>double precision </type> <parameter>initialvalue</parameter></paramdef>
|
|
<paramdef><type>double precision </type> <parameter>nodataval</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns a raster with a new band added in given position (band number), of given type, of given intial value, and of given nodata value. If no index is specified, the band is added to the end. Pixel type is a string representation
|
|
of one of the pixel types specified in <xref linkend="RT_ST_BandPixelType" />. If an existing index is specfied all subsequent bands >= that index are incremented by 1.
|
|
If an initial value greater than the max of the pixel type is specified, then the initial value is set to the highest value allowed by the pixel type. </para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>-- Add another band of type 8 bit unsigned integer with pixels initialized to 200
|
|
UPDATE dummy_rast
|
|
SET rast = ST_AddBand(rast,'8BUI',200)
|
|
WHERE rid = 1;
|
|
</programlisting>
|
|
|
|
<programlisting>-- Create an empty raster 100x100 units, with upper left right at 0, add 2 bands (band 1 is 0/1 bit switches, band2 1-4)
|
|
INSERT INTO dummy_rast(rid,rast)
|
|
VALUES(10, ST_AddBand(ST_AddBand(ST_MakeEmptyRaster(100,100,0,0,1,-1,0,0, -1), '2BUI'), '4BUI') );
|
|
|
|
-- output meta data of raster bands to verify all is right --
|
|
SELECT (bmd).*
|
|
FROM (SELECT ST_BandMetaData(rast,generate_series(1,2)) As bmd
|
|
FROM dummy_rast WHERE rid = 10) AS foo;
|
|
--result --
|
|
pixeltype | hasnodatavalue | nodatavalue | isoutdb | path
|
|
-----------+----------------+-------------+---------+------
|
|
2BUI | f | 0 | f |
|
|
4BUI | f | 0 | f |
|
|
|
|
|
|
-- output meta data of raster -
|
|
SELECT (rmd).width, (rmd).height, (rmd).numbands
|
|
FROM (SELECT ST_MetaData(rast) As rmd
|
|
FROM dummy_rast WHERE rid = 10) AS foo;
|
|
-- result --
|
|
upperleftx | upperlefty | width | height | pixelsizex | pixelsizey | skewx | skewy | srid | numbands
|
|
------------+------------+-------+--------+------------+------------+-------+-------+------+----------
|
|
0 | 0 | 100 | 100 | 1 | -1 | 0 | 0 | -1 | 2
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_BandMetaData" />, <xref linkend="RT_ST_BandPixelType" />, <xref linkend="RT_ST_MakeEmptyRaster" />, <xref linkend="RT_ST_MetaData" />, <xref linkend="RT_ST_NumBands" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
<refentry id="RT_ST_BandHasNoDataValue">
|
|
<refnamediv>
|
|
<refname>ST_BandHasNoDataValue</refname>
|
|
<refpurpose>Returns whether or not a band has a value that should be considered no data. If no band number provided 1 is assumed.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>boolean <function>ST_BandHasNoDataValue</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>boolean <function>ST_BandHasNoDataValue</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>bandnum</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns true or false whether or not a band has a value that should be considered no data. If no band number provided 1 is assumed.</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>-- change just first band no data value
|
|
SELECT ST_BandHasNoDataValue(rast,1) As hasnodataval
|
|
FROM dummy_rast
|
|
WHERE rid = 2;
|
|
|
|
hasnodataval
|
|
------------
|
|
f
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_SetBandNoDataValue" />,, <xref linkend="RT_ST_BandNoDataValue" />,<xref linkend="RT_ST_SetBandNoDataValue" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_BandMetaData">
|
|
<refnamediv>
|
|
<refname>ST_BandMetaData</refname>
|
|
<refpurpose>Returns basic meta data for a specific raster band. band num 1 is assumed if none-specified.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>record <function>ST_BandMetaData</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>record <function>ST_BandMetaData</function></funcdef>
|
|
<paramdef><type>raster </type><parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type><parameter>bandnum</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns basic meta data about a raster band. Columns returned
|
|
pixeltype | hasnodatavalue | nodatavalue | isoutdb | path.
|
|
</para>
|
|
<note>
|
|
If raster contains no bands then an error is thrown.
|
|
</note>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT rid, (foo.md).*
|
|
FROM (SELECT rid, ST_BandMetaData(rast,1) As md
|
|
FROM dummy_rast WHERE rid=2) As foo;
|
|
|
|
rid | pixeltype | hasnodatavalue | nodatavalue | isoutdb | path
|
|
-----+-----------+----------------+-------------+---------+------
|
|
2 | 8BUI | t | 0 | f |
|
|
</programlisting>
|
|
</refsection>
|
|
|
|
<!-- Optionally add a "See Also" section -->
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_MetaData" />, <xref linkend="RT_ST_BandPixelType" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_BandNoDataValue">
|
|
<refnamediv>
|
|
<refname>ST_BandNoDataValue</refname>
|
|
<refpurpose>Returns the value in a given band that represents no data. If no band num 1 is assumed.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>integer <function>ST_BandNoDataValue</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>integer <function>ST_BandNoDataValue</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>bandnum</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the value that represents no data for the band</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT ST_BandNoDataValue(rast,1) As bnval1,
|
|
ST_BandNoDataValue(rast,2) As bnval2, ST_BandNoDataValue(rast,3) As bnval3
|
|
FROM dummy_rast
|
|
WHERE rid = 2;
|
|
|
|
bnval1 | bnval2 | bnval3
|
|
--------+--------+--------
|
|
0 | 0 | 0
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_NumBands" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_BandPath">
|
|
<refnamediv>
|
|
<refname>ST_BandPath</refname>
|
|
<refpurpose>Returns system file path to a band stored in file system. If no bandnum specified, 1 is assumed.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_BandPath</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_BandPath</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>bandnum</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns system file path to a band. Throws an error if called with an in db band.</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting><!-- TODO: -->
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_BandPixelType">
|
|
<refnamediv>
|
|
<refname>ST_BandPixelType</refname>
|
|
<refpurpose>Returns the type of pixel for given band. If no bandnum specified, 1 is assumed.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_BandPixelType</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>text <function>ST_BandPixelType</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>bandnum</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the value that represents no data for the band</para>
|
|
<para>There are 11 pixel types. Pixel Types supported are as follows:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>1BB - 1-bit boolean</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>2BUI - 2-bit unsigned integer</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>4BUI - 4-bit unsigned integer </para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>8BSI - 8-bit signed integer </para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>8BUI - 8-bit unsigned integer</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>16BSI - 16-bit signed integer</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>16BUI - 16-bit unsigned integer</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>32BSI - 32-bit signed integer</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>32BUI - 32-bit unsigned integer</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>32BF - 32-bit float</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>64BF - 64-bit float</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT ST_BandPixelType(rast,1) As btype1,
|
|
ST_BandPixelType(rast,2) As btype2, ST_BandPixelType(rast,3) As btype3
|
|
FROM dummy_rast
|
|
WHERE rid = 2;
|
|
|
|
btype1 | btype2 | btype3
|
|
--------+--------+--------
|
|
8BUI | 8BUI | 8BUI
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_NumBands" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
</sect1>
|
|
|
|
<sect1 id="Raster_Pixel_Accessors">
|
|
<title>Raster Pixel Accessors and Settors</title>
|
|
|
|
<refentry id="RT_ST_PixelAsPolygon">
|
|
<refnamediv>
|
|
<refname>ST_PixelAsPolygon</refname>
|
|
<refpurpose>Returns the geometry that bounds the pixel (for now a rectangle) for a particular band, row, column. If no band
|
|
specified band num 1 is assumed.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>geometry <function>ST_PixelAsPolygon</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>columnx</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>rowy</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>geometry <function>ST_PixelAsPolygon</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>bandnum</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>columnx</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>rowy</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the geometry that bounds the pixel (for now a rectangle) for a particular band, row, column. If no band
|
|
specified band num 1 is assumed.</para>
|
|
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
<programlisting>
|
|
-- get raster pixel polygon
|
|
SELECT i,j, ST_AsText(ST_PixelAsPolygon(foo.rast, i,j)) As b1pgeom
|
|
FROM dummy_rast As foo
|
|
CROSS JOIN generate_series(1,2) As i
|
|
CROSS JOIN generate_series(1,1) As j
|
|
WHERE rid=2;
|
|
|
|
i | j | b1pgeom
|
|
---+---+-----------------------------------------------------------------------------
|
|
1 | 1 | POLYGON((3427927.75 5793244,3427927.8 5793244,3427927.8 5793243.95,...
|
|
2 | 1 | POLYGON((3427927.8 5793244,3427927.85 5793244,3427927.85 5793243.95, ..
|
|
</programlisting>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_DumpAsPolygons" />, <xref linkend="RT_ST_Intersection" />,
|
|
<xref linkend="ST_AsText" />
|
|
</para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_Value">
|
|
<refnamediv>
|
|
<refname>ST_Value</refname>
|
|
<refpurpose>Returns the value of a given band in a given columnx, rowy pixel or at a particular geometric point. Band numbers start at 1 and assumed to be 1 if not specified.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>double precision <function>ST_Value</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>geometry </type> <parameter>pt</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>double precision <function>ST_Value</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>bandnum</parameter></paramdef>
|
|
<paramdef><type>geometry </type> <parameter>pt</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>double precision <function>ST_Value</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>columnx</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>rowy</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>double precision <function>ST_Value</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>bandnum</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>columnx</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>rowy</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the value of a given band in a given columnx, rowy pixel. Band numbers start at 1.</para>
|
|
<note><para>Note that although the X and Ys of these are not in coordinates of the spatial system,
|
|
you can get that by the following relationship.</para>
|
|
<para>Coordinate upper left ppoint of a row column
|
|
is:
|
|
ST_SetSRID(ST_Point(ST_UpperLeftX(rast) + ST_PixelSizeX(rast)*columnx, ST_UpperLeftY(rast) + ST_PixelSizeY(rast)*columny), ST_SRID(rast))
|
|
</para>
|
|
<para>If you want the pixel box instead of the upper left point, you can use the ST_MakeEnvelope function and
|
|
translate it every x,y.</para>
|
|
</note>
|
|
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
<programlisting>
|
|
-- get raster values at particular postgis geometry points
|
|
-- the srid of your geometry should be same as for your raster
|
|
SELECT rid, ST_Value(rast, foo.pt_geom) As b1pval, ST_Value(rast, 2, foo.pt_geom) As b2pval
|
|
FROM dummy_rast CROSS JOIN (SELECT ST_SetSRID(ST_Point(3427927.77,5793243.76),-1) As pt_geom) As foo
|
|
WHERE rid=2;
|
|
|
|
rid | b1pval | b2pval
|
|
-----+--------+--------
|
|
2 | 252 | 79
|
|
|
|
|
|
-- general fictitious example using a real table
|
|
SELECT rid, ST_Value(rast, 3, sometable.geom) As b3pval
|
|
FROM sometable
|
|
WHERE ST_Intersects(rast,sometable.geom);
|
|
</programlisting>
|
|
<programlisting>
|
|
SELECT rid, ST_Value(rast, 1,1,1) As b1pval,
|
|
ST_Value(rast, 2,1,1) As b2pval, ST_Value(rast, 3,1,1) As b3pval
|
|
FROM dummy_rast
|
|
WHERE rid=2;
|
|
|
|
rid | b1pval | b2pval | b3pval
|
|
-----+--------+--------+--------
|
|
2 | 253 | 78 | 70
|
|
</programlisting>
|
|
|
|
<programlisting>
|
|
--- Get all values in bands 1,2,3 of each pixel --
|
|
SELECT x, y, ST_Value(rast, 1, x, y) As b1val,
|
|
ST_Value(rast, 2, x, y) As b2val, ST_Value(rast, 3, x, y) As b3val
|
|
FROM dummy_rast CROSS JOIN
|
|
generate_series(1,1000) As x CROSS JOIN generate_series(1,1000) As y
|
|
WHERE rid = 2 AND x <= ST_Width(rast) AND y <= ST_Height(rast);
|
|
|
|
x | y | b1val | b2val | b3val
|
|
---+---+-------+-------+-------
|
|
1 | 1 | 253 | 78 | 70
|
|
1 | 2 | 253 | 96 | 80
|
|
1 | 3 | 250 | 99 | 90
|
|
1 | 4 | 251 | 89 | 77
|
|
1 | 5 | 252 | 79 | 62
|
|
2 | 1 | 254 | 98 | 86
|
|
2 | 2 | 254 | 118 | 108
|
|
:
|
|
:
|
|
</programlisting>
|
|
|
|
<programlisting>
|
|
--- Get all values in bands 1,2,3 of each pixel same as above but returning the upper left point point of each pixel --
|
|
SELECT ST_AsText(ST_SetSRID(
|
|
ST_Point(ST_UpperLeftX(rast) + ST_PixelSizeX(rast)*x,
|
|
ST_UpperLeftY(rast) + ST_PixelSizeY(rast)*y),
|
|
ST_SRID(rast))) As uplpt
|
|
, ST_Value(rast, 1, x, y) As b1val,
|
|
ST_Value(rast, 2, x, y) As b2val, ST_Value(rast, 3, x, y) As b3val
|
|
FROM dummy_rast CROSS JOIN
|
|
generate_series(1,1000) As x CROSS JOIN generate_series(1,1000) As y
|
|
WHERE rid = 2 AND x <= ST_Width(rast) AND y <= ST_Height(rast);
|
|
|
|
uplpt | b1val | b2val | b3val
|
|
-----------------------------+-------+-------+-------
|
|
POINT(3427929.25 5793245.5) | 253 | 78 | 70
|
|
POINT(3427929.25 5793247) | 253 | 96 | 80
|
|
POINT(3427929.25 5793248.5) | 250 | 99 | 90
|
|
:
|
|
</programlisting>
|
|
<programlisting>
|
|
--- Get a polygon formed by union of all pixels
|
|
that fall in a particular value range and intersect particular polygon --
|
|
SELECT ST_AsText(ST_Union(pixpolyg)) As shadow
|
|
FROM (SELECT ST_Translate(ST_MakeEnvelope(
|
|
ST_UpperLeftX(rast), ST_UpperLeftY(rast),
|
|
ST_UpperLeftX(rast) + ST_PixelSizeX(rast),
|
|
ST_UpperLeftY(rast) + ST_PixelSizeY(rast), 0
|
|
), ST_PixelSizeX(rast)*x, ST_PixelSizeY(rast)*y
|
|
) As pixpolyg, ST_Value(rast, 2, x, y) As b2val
|
|
FROM dummy_rast CROSS JOIN
|
|
generate_series(1,1000) As x CROSS JOIN generate_series(1,1000) As y
|
|
WHERE rid = 2
|
|
AND x <= ST_Width(rast) AND y <= ST_Height(rast)) As foo
|
|
WHERE
|
|
ST_Intersects(
|
|
pixpolyg,
|
|
ST_GeomFromText('POLYGON((3427928 5793244,3427927.75 5793243.75,3427928 5793243.75,3427928 5793244))',0)
|
|
) AND b2val != 254;
|
|
|
|
|
|
shadow
|
|
------------------------------------------------------------------------------------
|
|
MULTIPOLYGON(((3427928 5793243.9,3427928 5793243.85,3427927.95 5793243.85,3427927.95 5793243.9,
|
|
3427927.95 5793243.95,3427928 5793243.95,3427928.05 5793243.95,3427928.05 5793243.9,3427928 5793243.9)),((3427927.95 5793243.9,3427927.95 579324
|
|
3.85,3427927.9 5793243.85,3427927.85 5793243.85,3427927.85 5793243.9,3427927.9 5793243.9,3427927.9 5793243.95,
|
|
3427927.95 5793243.95,3427927.95 5793243.9)),((3427927.85 5793243.75,3427927.85 5793243.7,3427927.8 5793243.7,3427927.8 5793243.75
|
|
,3427927.8 5793243.8,3427927.8 5793243.85,3427927.85 5793243.85,3427927.85 5793243.8,3427927.85 5793243.75)),
|
|
((3427928.05 5793243.75,3427928.05 5793243.7,3427928 5793243.7,3427927.95 5793243.7,3427927.95 5793243.75,3427927.95 5793243.8,3427
|
|
927.95 5793243.85,3427928 5793243.85,3427928 5793243.8,3427928.05 5793243.8,
|
|
3427928.05 5793243.75)),((3427927.95 5793243.75,3427927.95 5793243.7,3427927.9 5793243.7,3427927.85 5793243.7,
|
|
3427927.85 5793243.75,3427927.85 5793243.8,3427927.85 5793243.85,3427927.9 5793243.85,
|
|
3427927.95 5793243.85,3427927.95 5793243.8,3427927.95 5793243.75)))
|
|
</programlisting>
|
|
|
|
<programlisting>
|
|
--- Checking all the pixels of a large raster tile can take a long time.
|
|
--- You can dramatically improve speed at some lose of precision by orders of magnitude
|
|
-- by sampling pixels using the step optional parameter of generate_series.
|
|
-- This next example does the same as previous but by checking 1 for every 4 (2x2) pixels and putting in the last checked
|
|
-- putting in the checked pixel as the value for subsequent 4
|
|
|
|
SELECT ST_AsText(ST_Union(pixpolyg)) As shadow
|
|
FROM (SELECT ST_Translate(ST_MakeEnvelope(
|
|
ST_UpperLeftX(rast), ST_UpperLeftY(rast),
|
|
ST_UpperLeftX(rast) + ST_PixelSizeX(rast)*2,
|
|
ST_UpperLeftY(rast) + ST_PixelSizeY(rast)*2, 0
|
|
), ST_PixelSizeX(rast)*x, ST_PixelSizeY(rast)*y
|
|
) As pixpolyg, ST_Value(rast, 2, x, y) As b2val
|
|
FROM dummy_rast CROSS JOIN
|
|
generate_series(1,1000,2) As x CROSS JOIN generate_series(1,1000,2) As y
|
|
WHERE rid = 2
|
|
AND x <= ST_Width(rast) AND y <= ST_Height(rast) ) As foo
|
|
WHERE
|
|
ST_Intersects(
|
|
pixpolyg,
|
|
ST_GeomFromText('POLYGON((3427928 5793244,3427927.75 5793243.75,3427928 5793243.75,3427928 5793244))',0)
|
|
) AND b2val != 254;
|
|
|
|
shadow
|
|
------------------------------------------------------------------------------------
|
|
MULTIPOLYGON(((3427927.9 5793243.85,3427927.8 5793243.85,3427927.8 5793243.95,
|
|
3427927.9 5793243.95,3427928 5793243.95,3427928.1 5793243.95,3427928.1 5793243.85,3427928 5793243.85,3427927.9 5793243.85)),
|
|
((3427927.9 5793243.65,3427927.8 5793243.65,3427927.8 5793243.75,3427927.8 5793243.85,3427927.9 5793243.85,
|
|
3427928 5793243.85,3427928 5793243.75,3427928.1 5793243.75,3427928.1 5793243.65,3427928 5793243.65,3427927.9 5793243.65)))
|
|
</programlisting>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_DumpAsPolygons" />, <xref linkend="RT_ST_NumBands" />, <xref linkend="RT_ST_PixelSizeX" />,
|
|
, <xref linkend="RT_ST_PixelSizeY" />, <xref linkend="RT_ST_UpperLeftX" />,
|
|
<xref linkend="RT_ST_UpperLeftY" />, <xref linkend="RT_ST_SRID" />, <xref linkend="ST_AsText" />,
|
|
, <xref linkend="ST_Point" />, <xref linkend="ST_MakeEnvelope" />,
|
|
<xref linkend="ST_Intersects" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_SetValue">
|
|
<refnamediv>
|
|
<refname>ST_SetValue</refname>
|
|
<refpurpose>Sets the value of a given band in a given columnx, rowy pixel or at a pixel that intersects a particular geometric point. Band numbers start at 1 and assumed to be 1 if not specified.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>double precision <function>ST_SetValue</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>geometry </type> <parameter>pt</parameter></paramdef>
|
|
<paramdef><type>double precision </type> <parameter>newvalue</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>double precision <function>ST_SEtValue</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>bandnum</parameter></paramdef>
|
|
<paramdef><type>geometry </type> <parameter>pt</parameter></paramdef>
|
|
<paramdef><type>double precision </type> <parameter>newvalue</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>double precision <function>ST_SetValue</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>columnx</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>rowy</parameter></paramdef>
|
|
<paramdef><type>double precision </type> <parameter>newvalue</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>double precision <function>ST_SetValue</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>bandnum</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>columnx</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>rowy</parameter></paramdef>
|
|
<paramdef><type>double precision </type> <parameter>newvalue</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
<para>Sets the specified pixel value to new value for the designed band given the row column location or a goemetric point location.
|
|
If no band is specified, then band 1 is assumed.
|
|
</para>
|
|
<note><para>Setting by geometry currently only works for points.</para></note>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>
|
|
-- Geometry example
|
|
SELECT (foo.geomval).val, ST_AsText(ST_Union((foo.geomval).geom))
|
|
FROM (SELECT ST_DumpAsPolygons(
|
|
ST_SetValue(rast,1,
|
|
ST_Point(3427927.75, 5793243.95),
|
|
50)
|
|
) As geomval
|
|
FROM dummy_rast
|
|
where rid = 2) As foo
|
|
WHERE (foo.geomval).val < 250
|
|
GROUP BY (foo.geomval).val;
|
|
|
|
val | st_astext
|
|
-----+-------------------------------------------------------------------
|
|
50 | POLYGON((3427927.75 5793244,3427927.75 5793243.95,3427927.8 579324 ...
|
|
249 | POLYGON((3427927.95 5793243.95,3427927.95 5793243.85,3427928 57932 ...
|
|
</programlisting>
|
|
</refsection>
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_Value" />, <xref linkend="RT_ST_DumpAsPolygons" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
</sect1>
|
|
|
|
<sect1 id="Raster_Editors">
|
|
<title>Raster Editors</title>
|
|
|
|
<refentry id="RT_ST_SetGeoReference">
|
|
<refnamediv>
|
|
<refname>ST_SetGeoReference</refname>
|
|
<refpurpose>Set Georefence 6 georeference parameters in a single call. Numbers should be separated by white space. Accepts inputs in GDAL or ESRI format. Default is GDAL.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>raster <function>ST_SetGeoReference</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>text </type> <parameter>georefcoords</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>raster <function>ST_SetGeoReference</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>text </type> <parameter>georefcoords</parameter></paramdef>
|
|
<paramdef><type>text </type> <parameter>format</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Set Georefence 6 georeference parameters in a single call. Accepts inputs in 'GDAL' or 'ESRI' format. Default is GDAL. If 6 coordinates are not provided will return null.</para>
|
|
<para>Difference between format representations is as follows:</para>
|
|
<para><varname>GDAL</varname>:
|
|
<programlisting>pixelsizex skewy skewx pixelsizey upperleftx upperlefty</programlisting></para>
|
|
<para><varname>ESRI</varname>:
|
|
<programlisting>pixelsizex skewy skewx pixelsizey upperleftx + pixelsizex*0.5 upperlefty + pixelsizey*0.5</programlisting></para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>UPDATE dummy_rast SET rast = ST_SetGeoReference(rast, '2 0 0 3 0.5 0.5','GDAL')
|
|
WHERE rid=1;
|
|
|
|
-- same coordinates set in 'ESRI' format
|
|
UPDATE dummy_rast SET rast = ST_SetGeoReference(rast, '2 0 0 3 1.5 2','ESRI')
|
|
WHERE rid=1;
|
|
</programlisting>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_GeoReference" />, <xref linkend="RT_ST_PixelSizeX" />, <xref linkend="RT_ST_PixelSizeY" />, <xref linkend="RT_ST_UpperLeftX" />, <xref linkend="RT_ST_UpperLeftY" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_SetPixelSize">
|
|
<refnamediv>
|
|
<refname>ST_SetPixelSize</refname>
|
|
<refpurpose>Sets the x and y size of pixels in units of coordinate reference system. Number units/pixel width/height</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>raster <function>ST_SetPixelSize</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>float8 </type> <parameter>xy</parameter></paramdef>
|
|
</funcprototype>
|
|
|
|
<funcprototype>
|
|
<funcdef>raster <function>ST_SetPixelSize</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>float8 </type> <parameter>x</parameter></paramdef>
|
|
<paramdef><type>float8 </type> <parameter>y</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Sets the x and y size of pixels in units of coordinate reference system. Number units/pixel width/height. If
|
|
only one unit passed in, assumed x and y are the same number.</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>UPDATE dummy_rast
|
|
SET rast = ST_SetPixelSize(rast,1.5)
|
|
WHERE rid = 2;
|
|
|
|
SELECT ST_PixelSizeX(rast) As pixx, ST_PixelSizeY(rast) As pixy, ST_Box2D(rast) As newbox
|
|
FROM dummy_rast
|
|
WHERE rid = 2;
|
|
|
|
pixx | pixy | newbox
|
|
------+------+----------------------------------------------
|
|
1.5 | 1.5 | BOX(3427927.75 5793244,3427935.25 5793251.5)
|
|
</programlisting>
|
|
<programlisting>UPDATE dummy_rast
|
|
SET rast = ST_SetPixelSize(rast,1.5,0.55)
|
|
WHERE rid = 2;
|
|
|
|
SELECT ST_PixelSizeX(rast) As pixx, ST_PixelSizeY(rast) As pixy, ST_Box2D(rast) As newbox
|
|
FROM dummy_rast
|
|
WHERE rid = 2;
|
|
|
|
pixx | pixy | newbox
|
|
------+------+--------------------------------------------
|
|
1.5 | 0.55 | BOX(3427927.75 5793244,3427935.25 5793247)
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_PixelSizeX" />, <xref linkend="RT_ST_PixelSizeY" />, <xref linkend="RT_ST_Box2D" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_SetSkew">
|
|
<refnamediv>
|
|
<refname>ST_SetSkew</refname>
|
|
<refpurpose>Sets the georeference X and Y skew (or rotation parameter). If only one is passed in sets x and y to same number.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>raster <function>ST_SetSkew</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>float8 </type> <parameter>skewxy</parameter></paramdef>
|
|
</funcprototype>
|
|
<funcprototype>
|
|
<funcdef>raster <function>ST_SetSkew</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>float8 </type> <parameter>skewx</parameter></paramdef>
|
|
<paramdef><type>float8 </type> <parameter>skewy</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Sets the georeference X and Y skew (or rotation parameter). If only one is passed in sets x and y to same number. Refer to <ulink url="http://en.wikipedia.org/wiki/World_file">World File</ulink>
|
|
for more details.</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>
|
|
-- Example 1
|
|
UPDATE dummy_rast SET rast = ST_SetSkew(rast,1,2) WHERE rid = 1;
|
|
SELECT rid, ST_SkewX(rast) As skewx, ST_SkewY(rast) As skewy,
|
|
ST_GeoReference(rast) as georef
|
|
FROM dummy_rast WHERE rid = 1;
|
|
|
|
rid | skewx | skewy | georef
|
|
----+-------+-------+--------------
|
|
1 | 1 | 2 | 2.0000000000
|
|
: 2.0000000000
|
|
: 1.0000000000
|
|
: 3.0000000000
|
|
: 0.5000000000
|
|
: 0.5000000000
|
|
|
|
</programlisting>
|
|
|
|
<programlisting>
|
|
-- Example 2 set both to same number:
|
|
UPDATE dummy_rast SET rast = ST_SetSkew(rast,0) WHERE rid = 1;
|
|
SELECT rid, ST_SkewX(rast) As skewx, ST_SkewY(rast) As skewy,
|
|
ST_GeoReference(rast) as georef
|
|
FROM dummy_rast WHERE rid = 1;
|
|
|
|
rid | skewx | skewy | georef
|
|
-----+-------+-------+--------------
|
|
1 | 0 | 0 | 2.0000000000
|
|
: 0.0000000000
|
|
: 0.0000000000
|
|
: 3.0000000000
|
|
: 0.5000000000
|
|
: 0.5000000000
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<!-- Optionally add a "See Also" section -->
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_GeoReference" />,<xref linkend="RT_ST_SetGeoReference" />, <xref linkend="RT_ST_SkewX" />, <xref linkend="RT_ST_SkewY" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_SetSRID">
|
|
<refnamediv>
|
|
<refname>ST_SetSRID</refname>
|
|
|
|
<refpurpose>Sets the SRID of a raster to a particular integer srid defined in the spatial_ref_sys table.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>raster <function>ST_SetSRID</function></funcdef>
|
|
|
|
<paramdef><type>raster </type>
|
|
<parameter>rast</parameter></paramdef>
|
|
|
|
<paramdef><type>integer </type>
|
|
<parameter>srid</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Sets the SRID on a raster to a particular integer value.</para>
|
|
|
|
<note>
|
|
<para>This function does not transform the raster in any way -
|
|
it simply sets meta data defining the spatial ref of the coordinate reference system that it's currently in.
|
|
Useful for transformations later.
|
|
</para>
|
|
</note>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
|
|
<para><xref linkend="spatial_ref_sys" />, <xref linkend="RT_ST_SRID"/></para>
|
|
</refsection>
|
|
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_SetUpperLeft">
|
|
<refnamediv>
|
|
<refname>ST_SetUpperLeft</refname>
|
|
<refpurpose>Sets the value of the upper left corner of the pixel to projected x,y coordinates</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>raster <function>ST_SetUpperLeft</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>double precision </type> <parameter>x</parameter></paramdef>
|
|
<paramdef><type>double precision </type> <parameter>y</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Set the value of the uppler left corner of raster to the projected x coordinates</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>
|
|
SELECT ST_SetUpperLeft(rast,-71.01,42.37)
|
|
FROM dummy_rast
|
|
WHERE rid = 2;
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_UpperLeftX" />,<xref linkend="RT_ST_UpperLeftY" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
</sect1>
|
|
<sect1 id="RasterBand_Editors">
|
|
<title>Raster Band Editors</title>
|
|
<refentry id="RT_ST_SetBandHasNoDataValue">
|
|
<refnamediv>
|
|
<refname>ST_SetBandHasNoDataValue</refname>
|
|
<refpurpose>Sets whether or not a band has a value that should be considered no data.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>raster <function>ST_SetBandHasNoDataValue</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>bandnum</parameter></paramdef>
|
|
<paramdef><type>boolean </type> <parameter>has_nodatavalue</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Sets whether or not a band has a value that should be considered no data.</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>-- change just first band no data value
|
|
UPDATE dummy_rast
|
|
SET rast = ST_SetBandHasNoDataValue(rast,1, false)
|
|
WHERE rid = 2;
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_BandNoDataValue" />,<xref linkend="RT_ST_SetBandNoDataValue" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_SetBandNoDataValue">
|
|
<refnamediv>
|
|
<refname>ST_SetBandNoDataValue</refname>
|
|
<refpurpose>Sets the value for the given band that represents no data.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>integer <function>ST_SetBandNoDataValue</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>bandnum</parameter></paramdef>
|
|
<paramdef><type>double precision </type> <parameter>val</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Sets the value that represents no data for the band. This will effect <xref linkend="RT_ST_Polygon" /> and <xref linkend="RT_ST_ConvexHull" /> results.</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>-- change just first band no data value
|
|
UPDATE dummy_rast
|
|
SET rast = ST_SetBandNoDataValue(rast,1, 254)
|
|
WHERE rid = 2;
|
|
|
|
-- change no data band value of bands 1,2,3
|
|
UPDATE dummy_rast
|
|
SET rast =
|
|
ST_SetBandNoDataValue(
|
|
ST_SetBandNoDataValue(
|
|
ST_SetBandNoDataValue(
|
|
rast,1, 254)
|
|
,2,99),
|
|
3,108)
|
|
WHERE rid = 2;
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_BandNoDataValue" />,<xref linkend="RT_ST_NumBands" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
</sect1>
|
|
|
|
<sect1 id="Raster_Outputs">
|
|
<title>Raster Outputs</title>
|
|
<refentry id="RT_ST_AsBinary">
|
|
<refnamediv>
|
|
<refname>ST_AsBinary</refname>
|
|
<refpurpose>Return the Well-Known Binary (WKB) representation of the raster without SRID meta data.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>bytea <function>ST_AsBinary</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the Binary representation of the raster. There are 2 variants of the function. The first
|
|
variant takes no endian encoding paramater and defaults to little endian. The second variant takes a second argument
|
|
denoting the encoding - using little-endian ('NDR') or big-endian ('XDR') encoding.</para>
|
|
<para>This is useful in binary cursors to pull data out of the
|
|
database without converting it to a string representation.</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT ST_AsBinary(rast) As rastbin
|
|
FROM dummy_rast WHERE rid=1;
|
|
|
|
rastbin
|
|
---------------------------------------------------------------------------------
|
|
\001\000\000\000\000\000\000\000\000\000\000\000@\000\000\000\000\000\000\010@\
|
|
000\000\000\000\000\000\340?\000\000\000\000\000\000\340?\000\000\000\000\000\00
|
|
0\000\000\000\000\000\000\000\000\000\000\012\000\000\000\012\000\024\000
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<!-- Optionally add a "See Also" section -->
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para></para>
|
|
</refsection>
|
|
</refentry>
|
|
</sect1>
|
|
|
|
<sect1 id="Raster_Processing">
|
|
<title>Raster Processing Functions</title>
|
|
<refentry id="RT_ST_Box2D">
|
|
<refnamediv>
|
|
<refname>ST_Box2D</refname>
|
|
<refpurpose>Returns the box 2d representation of the enclosing box of the raster</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>box2d <function>ST_Box2D</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the box representing the extent of the raster.</para>
|
|
<para>The polygon is defined by the corner points of the bounding box
|
|
((<varname>MINX</varname>, <varname>MINY</varname>),
|
|
(<varname>MAXX</varname>, <varname>MAXY</varname>))</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT rid, ST_Box2D(rast) As rastbox
|
|
FROM dummy_rast;
|
|
|
|
rid | rastbox
|
|
----+-------------------------------------------------
|
|
1 | BOX(0.5 0.5,20.5 60.5)
|
|
2 | BOX(3427927.75 5793243.5,3427928 5793244)
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_Envelope" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_ConvexHull">
|
|
<refnamediv>
|
|
<refname>ST_ConvexHull</refname>
|
|
<refpurpose>Return the convex hull geometry of the raster including pixel values equal to BandNoDataValue.
|
|
For regular shaped and non-skewed
|
|
rasters, this gives the same answer as ST_Envelope so only useful for irregularly shaped or skewed rasters.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>geometry <function>ST_ConvexHull</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Return the convex hull geometry of the raster including the NoDataBandValue band pixels. For regular shaped and non-skewed
|
|
rasters, this gives more or less the same answer as ST_Envelope
|
|
so only useful for irregularly shaped or skewed rasters.</para>
|
|
|
|
<para><note>ST_Envelope floors the coordinates and hence add a little buffer around the raster so the answer is subtley
|
|
different from ST_ConvexHull which does not floor.</note>
|
|
</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
<para>Refer to <ulink url="http://trac.osgeo.org/postgis/wiki/WKTRaster/SpecificationWorking01">PostGIS Raster Specification</ulink>
|
|
for a diagram of this.</para>
|
|
<informaltable>
|
|
<tgroup cols="1">
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para> <!-- TODO: Put in pictures -->
|
|
<programlisting>-- Note envelope and convexhull are more or less the same
|
|
SELECT ST_AsText(ST_ConvexHull(rast)) As convhull,
|
|
ST_AsText(ST_Envelope(rast)) As env
|
|
FROM dummy_rast WHERE rid=1;
|
|
|
|
convhull | env
|
|
|
|
--------------------------------------------------------+-----------------------
|
|
POLYGON((0.5 0.5,20.5 0.5,20.5 60.5,0.5 60.5,0.5 0.5)) | POLYGON((0 0,20 0,20 60,0 60,0 0))
|
|
</programlisting>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para> <!-- TODO: Put in pictures -->
|
|
<programlisting>
|
|
-- now we skew the raster
|
|
-- note how the convex hull and envelope are now different
|
|
SELECT ST_AsText(ST_ConvexHull(rast)) As convhull,
|
|
ST_AsText(ST_Envelope(rast)) As env
|
|
FROM (SELECT ST_SetRotation(rast,0.1,0.1) As rast
|
|
FROM dummy_rast WHERE rid=1) As foo;
|
|
|
|
convhull | env
|
|
|
|
--------------------------------------------------------+------------------------------------
|
|
POLYGON((0.5 0.5,20.5 1.5,22.5 61.5,2.5 60.5,0.5 0.5)) | POLYGON((0 0,22 0,22 61,0 61,0 0))
|
|
</programlisting>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsection>
|
|
|
|
<!-- Optionally add a "See Also" section -->
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_Envelope" />, <xref linkend="ST_ConvexHull" />, <xref linkend="ST_AsText" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_DumpAsPolygons">
|
|
<refnamediv>
|
|
<refname>ST_DumpAsPolygons</refname>
|
|
<refpurpose>Returns a set of geomval (geom,val) rows, from a given raster band. If no band number is specified, band num defaults to 1.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>setof geomval <function>ST_DumpAsPolygons</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
|
|
<funcprototype>
|
|
<funcdef>setof geomval <function>ST_DumpAsPolygons</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>band_num</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
<para>This is a set-returning function (SRF). It returns a set of
|
|
geomval rows, formed by a geometry (geom) and a pixel band value (val).
|
|
Each polygon is the union of all pixels for that band that have the same pixel value denoted by val.</para>
|
|
|
|
<para>ST_DumpAsPolygon is useful for polygonizing rasters. It is the
|
|
reverse of a GROUP BY in that it creates new rows. For example it
|
|
can be used to expand a single raster into multiple POLYGONS/MULTIPOLYGONS.</para>
|
|
|
|
<para>Availability: Requires GDAL 1.7 or higher.</para>
|
|
<note><para>If there is a no data value set for a band, pixels with that value will not be returned.</para></note>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
<programlisting>SELECT val, ST_AsText(geom) As geomwkt
|
|
FROM (
|
|
SELECT (ST_DumpAsPolygons(rast)).*
|
|
FROM dummy_rast
|
|
WHERE rid = 2
|
|
) As foo
|
|
WHERE val BETWEEN 249 and 251
|
|
ORDER BY val;
|
|
|
|
val | geomwkt
|
|
-----+--------------------------------------------------------------------------
|
|
249 | POLYGON((3427927.95 5793243.95,3427927.95 5793243.85,3427928 5793243.85,
|
|
3427928 5793243.95,3427927.95 5793243.95))
|
|
250 | POLYGON((3427927.75 5793243.9,3427927.75 5793243.85,3427927.8 5793243.85,
|
|
3427927.8 5793243.9,3427927.75 5793243.9))
|
|
250 | POLYGON((3427927.8 5793243.8,3427927.8 5793243.75,3427927.85 5793243.75,
|
|
3427927.85 5793243.8, 3427927.8 5793243.8))
|
|
251 | POLYGON((3427927.75 5793243.85,3427927.75 5793243.8,3427927.8 5793243.8,
|
|
3427927.8 5793243.85,3427927.75 5793243.85))
|
|
</programlisting>
|
|
</refsection>
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_Value" />, <xref linkend="RT_ST_Polygon" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_Envelope">
|
|
<refnamediv>
|
|
<refname>ST_Envelope</refname>
|
|
<refpurpose>Returns the polygon representation of the extent of the raster.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>geometry <function>ST_Envelope</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns the polygon representation of the extent of the raster in spatial coordinate units defiend by srid. It is a float8 minimum bounding box represented as a polygon. </para>
|
|
<para>The polygon is defined by the corner points of the bounding box
|
|
((<varname>MINX</varname>, <varname>MINY</varname>),
|
|
(<varname>MINX</varname>, <varname>MAXY</varname>),
|
|
(<varname>MAXX</varname>, <varname>MAXY</varname>),
|
|
(<varname>MAXX</varname>, <varname>MINY</varname>),
|
|
(<varname>MINX</varname>, <varname>MINY</varname>))</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT rid, ST_AsText(ST_Envelope(rast)) As envgeomwkt
|
|
FROM dummy_rast;
|
|
|
|
rid | envgeomwkt
|
|
-----+--------------------------------------------------------------------
|
|
1 | POLYGON((0 0,20 0,20 60,0 60,0 0))
|
|
2 | POLYGON((3427927 5793243,3427928 5793243,
|
|
3427928 5793244,3427927 5793244, 3427927 5793243))
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="ST_Envelope" />, <xref linkend="ST_AsText" />, <xref linkend="RT_ST_SRID" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_Intersection">
|
|
<refnamediv>
|
|
<refname>ST_Intersection</refname>
|
|
<refpurpose>Returns a set of geometry-pixelvalue pairs resulting from intersection of a raster band with a geometry. If
|
|
no band number is specified, band 1 is assumed.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>setof geomval <function>ST_Intersection</function></funcdef>
|
|
<paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
|
|
<funcprototype>
|
|
<funcdef>setof geomval <function>ST_Intersection</function></funcdef>
|
|
<paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>band_num</parameter></paramdef>
|
|
</funcprototype>
|
|
|
|
<funcprototype>
|
|
<funcdef>setof geomval <function>ST_Intersection</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
|
|
</funcprototype>
|
|
|
|
<funcprototype>
|
|
<funcdef>setof geomval <function>ST_Intersection</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>band_num</parameter></paramdef>
|
|
<paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Return the intersections of the geometry with the vectorized parts of
|
|
the raster and the values associated with those parts, if really their intersection is not empty. If no band number is specified
|
|
band 1 is assumed.</para>
|
|
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT foo.rid, foo.gid,
|
|
ST_AsText((foo.geomval).geom) As geomwkt, (foo.geomval).val
|
|
FROM
|
|
(
|
|
SELECT A.rid, g.gid , ST_Intersection(A.rast, g.geom) As geomval
|
|
FROM dummy_rast AS A CROSS JOIN
|
|
(VALUES (1, ST_Point(3427928, 5793243.85) ) ,
|
|
(2, ST_GeomFromText('LINESTRING(3427927.85 5793243.75,3427927.8 5793243.75,3427927.8 5793243.8)') ),
|
|
(3, ST_GeomFromText('LINESTRING(1 2, 3 4)') )
|
|
) As g(gid,geom)
|
|
WHERE A.rid =2 ) As foo;
|
|
|
|
rid | gid | geomwkt | val
|
|
-----+-----+---------------------------------------------------------------------------------------------
|
|
2 | 1 | POINT(3427928 5793243.85) | 249
|
|
2 | 1 | POINT(3427928 5793243.85) | 253
|
|
2 | 2 | POINT(3427927.85 5793243.75) | 254
|
|
2 | 2 | POINT(3427927.8 5793243.8) | 251
|
|
2 | 2 | POINT(3427927.8 5793243.8) | 253
|
|
2 | 2 | LINESTRING(3427927.8 5793243.75,3427927.8 5793243.8) | 252
|
|
2 | 2 | MULTILINESTRING((3427927.8 5793243.8,3427927.8 5793243.75),...) | 250
|
|
2 | 3 | GEOMETRYCOLLECTION EMPTY
|
|
</programlisting>
|
|
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_Intersects" />, <xref linkend="ST_AsText" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_ST_Polygon">
|
|
<refnamediv>
|
|
<refname>ST_Polygon</refname>
|
|
<refpurpose>Returns a polygon geometry formed by the union of pixels that have a pixel value that is not no data value. If no band number is specified, band num defaults to 1.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>geometry <function>ST_Polygon</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
</funcprototype>
|
|
|
|
<funcprototype>
|
|
<funcdef>geometry <function>ST_Polygon</function></funcdef>
|
|
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
|
|
<paramdef><type>integer </type> <parameter>band_num</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
<para>Availability: Requires GDAL 1.7 or higher.</para>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
<programlisting>
|
|
-- by default no data band value is 0 or not set, so polygon will return a square polygon
|
|
SELECT ST_AsText(ST_Polygon(rast)) As geomwkt
|
|
FROM dummy_rast
|
|
WHERE rid = 2;
|
|
|
|
geomwkt
|
|
--------------------------------------------
|
|
POLYGON((3427927.8 5793243.75,3427927.75 5793243.75,3427927.75 5793243.8,3427927.75 5793243.85,3427927.75 5793243.9,
|
|
3427927.75 5793244,3427927.8 5793244,3427927.85 5793244,3427927.9 5793244,3427928 5793244,3427928 5793243.95,
|
|
3427928 5793243.85,3427928 5793243.8,3427928 5793243.75,3427927.85 5793243.75,3427927.8 5793243.75))
|
|
|
|
|
|
-- now we change the no data value of first band
|
|
UPDATE dummy_rast SET rast = ST_SetBandNoDataValue(rast,1,254)
|
|
WHERE rid = 2;
|
|
SELECt rid, ST_BandNoDataValue(rast)
|
|
from dummy_rast where rid = 2;
|
|
|
|
-- ST_Polygon excludes the pixel value 254 and returns a multipolygon
|
|
SELECT ST_AsText(ST_Polygon(rast)) As geomwkt
|
|
FROM dummy_rast
|
|
WHERE rid = 2;
|
|
|
|
geomwkt
|
|
---------------------------------------------------------
|
|
MULTIPOLYGON(((3427927.9 5793243.95,3427927.85 5793243.95,3427927.85 5793244,3427927.9 5793244,3427927.9 5793243.95)),
|
|
((3427928 5793243.85,3427928 5793243.8,3427927.95 5793243.8,3427927.95 5793243.85,3427927.9 5793243.85,3427927.9 5793243.9,3427927.9 5793243.95,3427927.95 5793243.95,3427928 5793243.95,3427928 5793243.85)),
|
|
((3427927.8 5793243.75,3427927.75 5793243.75,3427927.75 5793243.8,3427927.75 5793243.85,3427927.75 5793243.9,3427927.75 5793244,3427927.8 5793244,
|
|
3427927.8 5793243.9,3427927.8 5793243.85,3427927.85 5793243.85,3427927.85 5793243.8,3427927.85 5793243.75,3427927.8 5793243.75)))
|
|
|
|
-- Or if you want the no data value different for just one time
|
|
|
|
SELECT ST_AsText(
|
|
ST_Polygon(
|
|
ST_SetBandNoDataValue(rast,1,252)
|
|
)
|
|
) As geomwkt
|
|
FROM dummy_rast
|
|
WHERE rid =2;
|
|
|
|
geomwkt
|
|
---------------------------------
|
|
POLYGON((3427928 5793243.85,3427928 5793243.8,3427928 5793243.75,3427927.85 5793243.75,3427927.8 5793243.75,3427927.8 5793243.8,3427927.75 5793243.8,3427927.75 5793243.85,3427927.75 5793243.9,3427927.75 5793244,3427927.8 5793244,3427927.85 5793244,3427927.9 5793244,3427928 5793244,3427928 5793243.95,3427928 5793243.85),
|
|
(3427927.9 5793243.9,3427927.9 5793243.85,3427927.95 5793243.85,3427927.95 5793243.9,3427927.9 5793243.9))
|
|
|
|
|
|
</programlisting>
|
|
</refsection>
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_Value" />, <xref linkend="RT_ST_DumpAsPolygons" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
</sect1>
|
|
|
|
<sect1 id="RT_Operators">
|
|
<title>Raster Operators</title>
|
|
<refentry id="RT_Raster_Overlap">
|
|
<refnamediv>
|
|
<refname>&&</refname>
|
|
|
|
<refpurpose>Returns <varname>TRUE</varname> if A's bounding box overlaps B's.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>boolean <function>&&</function></funcdef>
|
|
|
|
<paramdef>
|
|
<type>raster </type>
|
|
|
|
<parameter>A</parameter>
|
|
</paramdef>
|
|
|
|
<paramdef>
|
|
<type>raster </type>
|
|
|
|
<parameter>B</parameter>
|
|
</paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>The <varname>&&</varname> operator returns <varname>TRUE</varname> if the bounding box of raster A overlaps the bounding box of raster B.</para>
|
|
|
|
<note><para>This operand will make use of any indexes that may be available on the
|
|
rasters.</para></note>
|
|
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT A.rid As a_rid, B.rid As b_rid, A.rast && B.rast As overlap
|
|
FROM dummy_rast AS A CROSS JOIN dummy_rast AS B LIMIT 3;
|
|
|
|
a_rid | b_rid | overlap
|
|
-------+-------+---------
|
|
2 | 2 | t
|
|
2 | 3 | f
|
|
2 | 1 | f
|
|
</programlisting>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_Raster_OverLeft">
|
|
<refnamediv>
|
|
<refname>&<</refname>
|
|
|
|
<refpurpose>Returns <varname>TRUE</varname> if A's bounding box is to the left of B's.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>boolean <function>&<</function></funcdef>
|
|
|
|
<paramdef>
|
|
<type>raster </type>
|
|
|
|
<parameter>A</parameter>
|
|
</paramdef>
|
|
|
|
<paramdef>
|
|
<type>raster </type>
|
|
|
|
<parameter>B</parameter>
|
|
</paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>The <varname>&<</varname> operator returns <varname>TRUE</varname> if the bounding box of raster A
|
|
overlaps or is to the left of the bounding box of raster B, or more accurately, overlaps or is NOT to the right
|
|
of the bounding box of raster B.</para>
|
|
|
|
<note><para>This operand will make use of any indexes that may be available on the
|
|
geometries.</para></note>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT A.rid As a_rid, B.rid As b_rid, A.rast &< B.rast As overleft
|
|
FROM dummy_rast AS A CROSS JOIN dummy_rast AS B;
|
|
|
|
a_rid | b_rid | overleft
|
|
------+-------+----------
|
|
2 | 2 | t
|
|
2 | 3 | f
|
|
2 | 1 | f
|
|
3 | 2 | t
|
|
3 | 3 | t
|
|
3 | 1 | f
|
|
1 | 2 | t
|
|
1 | 3 | t
|
|
1 | 1 | t
|
|
</programlisting>
|
|
</refsection>
|
|
</refentry>
|
|
|
|
<refentry id="RT_Raster_OverRight">
|
|
<refnamediv>
|
|
<refname>&<</refname>
|
|
|
|
<refpurpose>Returns <varname>TRUE</varname> if A's bounding box is to the right of B's.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>boolean <function>&></function></funcdef>
|
|
|
|
<paramdef>
|
|
<type>raster </type>
|
|
|
|
<parameter>A</parameter>
|
|
</paramdef>
|
|
|
|
<paramdef>
|
|
<type>raster </type>
|
|
|
|
<parameter>B</parameter>
|
|
</paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>The <varname>&<</varname> operator returns <varname>TRUE</varname> if the bounding box of raster A
|
|
overlaps or is to the right of the bounding box of raster B, or more accurately, overlaps or is NOT to the left
|
|
of the bounding box of raster B.</para>
|
|
|
|
<note><para>This operand will make use of any indexes that may be available on the
|
|
geometries.</para></note>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT A.rid As a_rid, B.rid As b_rid, A.rast &> B.rast As overright
|
|
FROM dummy_rast AS A CROSS JOIN dummy_rast AS B;
|
|
|
|
a_rid | b_rid | overright
|
|
-------+-------+----------
|
|
2 | 2 | t
|
|
2 | 3 | t
|
|
2 | 1 | t
|
|
3 | 2 | f
|
|
3 | 3 | t
|
|
3 | 1 | f
|
|
1 | 2 | f
|
|
1 | 3 | t
|
|
1 | 1 | t
|
|
</programlisting>
|
|
</refsection>
|
|
</refentry>
|
|
</sect1>
|
|
|
|
<sect1 id="Raster_Relationships">
|
|
<title>Raster and Raster Band Spatial Relationships</title>
|
|
<refentry id="RT_ST_Intersects">
|
|
<refnamediv>
|
|
<refname>ST_Intersects</refname>
|
|
|
|
<refpurpose>Returns <varname>TRUE</varname> if rastA pixel in a band with non-no data band value intersects
|
|
with a geometry/raster. If band number is not specified it defaults to 1.</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>boolean <function>ST_Intersects</function></funcdef>
|
|
|
|
<paramdef>
|
|
<type>raster </type>
|
|
|
|
<parameter>rastA</parameter>
|
|
</paramdef>
|
|
|
|
<paramdef>
|
|
<type>geometry </type>
|
|
|
|
<parameter>geomB</parameter>
|
|
</paramdef>
|
|
</funcprototype>
|
|
|
|
<funcprototype>
|
|
<funcdef>boolean <function>ST_Intersects</function></funcdef>
|
|
|
|
<paramdef>
|
|
<type>raster </type>
|
|
|
|
<parameter>rastA</parameter>
|
|
</paramdef>
|
|
|
|
<paramdef>
|
|
<type>integer </type>
|
|
|
|
<parameter>band_num</parameter>
|
|
</paramdef>
|
|
|
|
<paramdef>
|
|
<type>geometry </type>
|
|
|
|
<parameter>geomB</parameter>
|
|
</paramdef>
|
|
</funcprototype>
|
|
|
|
<funcprototype>
|
|
<funcdef>boolean <function>ST_Intersects</function></funcdef>
|
|
|
|
<paramdef>
|
|
<type>geometry </type>
|
|
|
|
<parameter>geomA</parameter>
|
|
</paramdef>
|
|
|
|
<paramdef>
|
|
<type>raster </type>
|
|
|
|
<parameter>rastB</parameter>
|
|
</paramdef>
|
|
</funcprototype>
|
|
|
|
<funcprototype>
|
|
<funcdef>boolean <function>ST_Intersects</function></funcdef>
|
|
|
|
<paramdef>
|
|
<type>geometry </type>
|
|
|
|
<parameter>geomA</parameter>
|
|
</paramdef>
|
|
|
|
<paramdef>
|
|
<type>raster </type>
|
|
|
|
<parameter>rastB</parameter>
|
|
</paramdef>
|
|
|
|
<paramdef>
|
|
<type>integer </type>
|
|
<parameter>band_num</parameter>
|
|
</paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsection>
|
|
<title>Description</title>
|
|
|
|
<para>Returns true if any pixel in a raster band has a value that is not nodatavalue and that
|
|
geometry region of the pixel intersects the geometry</para>
|
|
|
|
<note><para>This operand will make use of any indexes that may be available on the
|
|
geometries / rasters.</para></note>
|
|
</refsection>
|
|
|
|
<refsection>
|
|
<title>Examples</title>
|
|
|
|
<programlisting>SELECT A.rid, g.gid , ST_Intersects(A.rast, g.geom) As inter
|
|
FROM dummy_rast AS A CROSS JOIN
|
|
(VALUES (1, ST_Point(3427928, 5793243.85) ) ,
|
|
(2, ST_GeomFromText('LINESTRING(3427927.85 5793243.75,3427927.8 5793243.75,3427927.8 5793243.8)') ),
|
|
(3, ST_GeomFromText('LINESTRING(1 2, 3 4)') )
|
|
) As g(gid,geom)
|
|
WHERE A.rid =2 ;
|
|
|
|
rid | gid | inter
|
|
-----+-----+-------
|
|
2 | 1 | t
|
|
2 | 2 | t
|
|
2 | 3 | f
|
|
</programlisting>
|
|
</refsection>
|
|
<refsection>
|
|
<title>See Also</title>
|
|
<para><xref linkend="RT_ST_Intersection" /></para>
|
|
</refsection>
|
|
</refentry>
|
|
</sect1>
|
|
</chapter>
|