move raster types to raster section (there are way too many now to try to lump into reference_type and do case statements to exclude from postgis_comments). Revise raster_comments to look for types in reference_raster. Add docu for ST_Reclass and reclassarg type. Need at least one more example to show how to use recalssargs.

git-svn-id: http://svn.osgeo.org/postgis/trunk@7304 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
Regina Obe 2011-06-01 08:17:27 +00:00
parent 12d22e5d9a
commit 4dc001d10a
3 changed files with 202 additions and 84 deletions

View file

@ -259,6 +259,109 @@ VALUES (1,
'41000000007719564100000000000000000000000000000000FFFFFFFF050005000400FDFEFDFEFEFDFEFEFDF9FAFEF' ||
'EFCF9FBFDFEFEFDFCFAFEFEFE04004E627AADD16076B4F9FE6370A9F5FE59637AB0E54F58617087040046566487A1506CA2E3FA5A6CAFFBFE4D566DA4CB3E454C5665')::raster);</programlisting>
</sect1>
<sect1 id="Raster_Types">
<title>Raster Support Data types</title>
<sect1info>
<abstract>
<para>This section lists the PostgreSQL data types specifically created to support raster functionality.</para>
</abstract>
</sect1info>
<refentry id="geomval">
<refnamediv>
<refname>geomval</refname>
<refpurpose>A spatial datatype with two fields - geom (holding a geometry object)
and val (holding a double precision pixel value from a raster band)</refpurpose>
</refnamediv>
<refsection>
<title>Description</title>
<para>geomval is a compound data type consisting of a geometry object referenced by the .geom field
and val, a double precision value that represents the pixel value at a particular geometric location in a raster band.
It is used by the ST_DumpAsPolygon and Raster intersection family of functions as an output type to explode a raster band into
geometry polygons.</para>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="PostGIS_Geometry_DumpFunctions" /> </para>
</refsection>
</refentry>
<refentry id="raster">
<refnamediv>
<refname>raster</refname>
<refpurpose>raster spatial data type.</refpurpose>
</refnamediv>
<refsection>
<title>Description</title>
<para>raster is a spatial data type used to represent raster data such as those imported from jpegs, tiffs, pngs, digital elevation models.
Each raster has 1 or more bands each having a set of pixel values. Rasters can be georeferenced.</para>
<note>
<para>Requires PostGIS be compiled with GDAL support. Currently rasters can be implicitly converted to geometry type, but the conversion returns the
<xref linkend="RT_ST_ConvexHull" /> of the raster. This auto casting may be removed in the near future so don't rely on it.</para>
</note>
</refsection>
<refsection>
<title>Casting Behavior</title>
<para>This section lists the automatic as well as explicit casts allowed for this data type</para>
<informaltable rowsep="1" frame="all">
<tgroup cols="2">
<tbody>
<row>
<entry>Cast To</entry>
<entry>Behavior</entry>
</row>
<row>
<entry>geometry</entry>
<entry>automatic</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="RT_reference" /></para>
</refsection>
</refentry>
<refentry id="reclassarg">
<refnamediv>
<refname>reclassarg</refname>
<refpurpose>A composite type used as input into the ST_Reclass function defining the behavior of reclassification.</refpurpose>
</refnamediv>
<refsection>
<title>Description</title>
<para>A composite type used as input into the ST_Reclass function defining the behavior of reclassification.</para>
<variablelist>
<varlistentry>
<term><parameter>nband</parameter><type>integer</type></term>
<listitem><para>The band number.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>reclassexpr</parameter><type>text</type></term>
<listitem><para>Mathemetical expression defining how to map band to new band.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>pixeltype</parameter><type>text</type></term>
<listitem><para>One of defined pixel types as described in <xref linkend="RT_ST_BandPixelType" /></para></listitem>
</varlistentry>
</variablelist>
</refsection>
<refsection>
<title>Example: Reclassify band 2 as an 8BUI where 255 is nodata value</title>
<programlisting>SELECT ROW(2, '0-100:1-10, 101-500:11-150,501 - 10000: 151-254', '8BUI', 255)::reclassarg;</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="RT_ST_Reclass" /></para>
</refsection>
</refentry>
</sect1>
<sect1 id="Raster_Management_Functions">
<title>Raster Management Functions</title>
<refentry id="RT_AddRasterColumn">
@ -4384,6 +4487,84 @@ POLYGON((3427928 5793243.85,3427928 5793243.8,3427928 5793243.75,3427927.85 5793
<para><xref linkend="RT_ST_Value" />, <xref linkend="RT_ST_DumpAsPolygons" /></para>
</refsection>
</refentry>
<refentry id="RT_ST_Reclass">
<refnamediv>
<refname>ST_Reclass</refname>
<refpurpose>Creates a new raster composed of band types reclassified from original. The nband is the band to be changed. If nband is not specified assumed to be 1. All other bands are returned unchanged.
Use case: convert a 16BUI band to a 2 8BUI and so forth for simpler rendering as viewable formats.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>raster <function>ST_Reclass</function></funcdef>
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
<paramdef><type>integer </type> <parameter>nband</parameter></paramdef>
<paramdef><type>text </type> <parameter>reclassexpr</parameter></paramdef>
<paramdef><type>text </type> <parameter>pixeltype</parameter></paramdef>
<paramdef choice='opt'><type>double precision </type> <parameter>nodataval=NULL</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>raster <function>ST_Reclass</function></funcdef>
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
<paramdef><type>reclassarg[] </type> <parameter>VARIADIC reclassargset</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>raster <function>ST_Reclass</function></funcdef>
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
<paramdef><type>text </type> <parameter>reclassexpr</parameter></paramdef>
<paramdef><type>text </type> <parameter>pixeltype</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Creates a new one band raster formed by applying a valid PostgreSQL algebraic operation defined by the <varname>expression</varname> on the input raster (<varname>rast</varname>). If no <varname>band</varname> is specified
band 1 is assumed. The new raster will have the same georeference, width, and height as the original raster but will only have one band.</para>
<para>The bands of the new raster will have pixel type of <varname>pixeltype</varname>. If <varname>reclassargset</varname> is passed in then each reclassarg defines behavior of each band generated.</para>
<para>Availability: 2.0.0 </para>
</refsection>
<refsection>
<title>Examples</title>
<para>Create a new raster from the original where band 2 is converted from 8BUI to 4BUI and all values from 251-255 are set to nodata value.</para>
<programlisting>ALTER TABLE dummy_rast ADD COLUMN reclass_rast raster;
UPDATE dummy_rast SET reclass_rast = ST_Reclass(rast,2,'0-100:1-10, 11-90:11-15, 91-254:0-0', '4BUI',0) WHERE rid = 2;
SELECT i as row, j as col, ST_Value(rast,2,i,j) As origval,
ST_Value(reclass_rast, 2, i, j) As reclassval,
ST_Value(reclass_rast, 2, i, j, false) As reclassval_include_nodata
FROM dummy_rast CROSS JOIN generate_series(1, 3) AS i CROSS JOIN generate_series(1,3) AS j
WHERE rid = 2;
row | col | origval | reclassval | reclassval_include_nodata
-----+-----+---------+------------+---------------------------
1 | 1 | 78 | 8 | 8
2 | 1 | 98 | 10 | 10
3 | 1 | 122 | | 0
1 | 2 | 96 | 10 | 10
2 | 2 | 118 | | 0
3 | 2 | 180 | | 0
1 | 3 | 99 | 10 | 10
2 | 3 | 112 | | 0
3 | 3 | 169 | | 0</programlisting>
<!-- TODO: Add more examples using reclass arg -->
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="RT_ST_BandPixelType" />, <xref linkend="reclassarg" /></para>
</refsection>
</refentry>
</sect1>
<sect1 id="RT_Operators">

View file

@ -17,7 +17,7 @@
<para><emphasis>At least as of PostgreSQL 8.3</emphasis> - Everything can be CAST to text (presumably because of the magical unknown type), so no defined CASTS for that need to be present for you to CAST an object to text.</para>
</abstract>
</sect1info>
<title>PostgreSQL PostGIS Types</title>
<title>PostgreSQL PostGIS Geometry/Geography/Box Types</title>
<refentry id="box2d">
<refnamediv>
@ -188,26 +188,6 @@
<para><xref linkend="PostGIS_Geometry_DumpFunctions" /> </para>
</refsection>
</refentry>
<refentry id="geomval">
<refnamediv>
<refname>geomval</refname>
<refpurpose>A spatial datatype with two fields - geom (holding a geometry object)
and val (holding a double precision pixel value from a raster band)</refpurpose>
</refnamediv>
<refsection>
<title>Description</title>
<para>geomval is a compound data type consisting of a geometry object referenced by the .geom field
and val, a double precision value that represents the pixel value at a particular geometric location in a raster band.
It is used by the ST_DumpAsPolygon and Raster intersection family of functions as an output type to explode a raster band into
geometry polygons.</para>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="PostGIS_Geometry_DumpFunctions" /> </para>
</refsection>
</refentry>
<refentry id="geography">
<refnamediv>
@ -244,45 +224,4 @@
<para><xref linkend="PostGIS_GeographyFunctions" />,<xref linkend="PostGIS_Geography" /></para>
</refsection>
</refentry>
<refentry id="raster">
<refnamediv>
<refname>raster</refname>
<refpurpose>raster spatial data type.</refpurpose>
</refnamediv>
<refsection>
<title>Description</title>
<para>raster is a spatial data type used to represent raster data such as those imported from jpegs, tiffs, pngs, digital elevation models.
Each raster has 1 or more bands each having a set of pixel values. Rasters can be georeferenced.</para>
<note>
<para>Requires PostGIS be compiled with GDAL support. Currently rasters can be implicitly converted to geometry type, but the conversion returns the
<xref linkend="RT_ST_ConvexHull" /> of the raster. This auto casting may be removed in the near future so don't rely on it.</para>
</note>
</refsection>
<refsection>
<title>Casting Behavior</title>
<para>This section lists the automatic as well as explicit casts allowed for this data type</para>
<informaltable rowsep="1" frame="all">
<tgroup cols="2">
<tbody>
<row>
<entry>Cast To</entry>
<entry>Behavior</entry>
</row>
<row>
<entry>geometry</entry>
<entry>automatic</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="RT_reference" /></para>
</refsection>
</refentry>
</sect1>

View file

@ -13,7 +13,7 @@
<!-- We deal only with the reference chapter -->
<xsl:template match="/">
<xsl:apply-templates select="/book/chapter[@id='RT_reference']" />
<xsl:apply-templates select="/book/chapter[@id='reference']/sect1[@id='PostGIS_Types']" />
<xsl:apply-templates select="/book/chapter[@id='RT_reference']/sect1[contains(@id, 'Type')]" />
</xsl:template>
<xsl:template match="chapter">
@ -41,27 +41,25 @@ COMMENT ON <xsl:choose><xsl:when test="contains(paramdef/type,'geometry set')">A
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template match="sect1[@id='PostGIS_Types']">
<xsl:for-each select="refentry">
<xsl:variable name="ap"><xsl:text>'</xsl:text></xsl:variable>
<xsl:choose>
<!-- If this is a raster type grab the ref entry summary and refname to make type comment -->
<xsl:when test="(contains(refnamediv/refname, 'raster') or contains(refnamediv/refname, 'geomval'))">
<xsl:variable name='plaincomment'>
<xsl:value-of select="normalize-space(translate(translate(refnamediv/refpurpose,'&#x0d;&#x0a;', ' '), '&#09;', ' '))"/>
</xsl:variable>
<!-- Replace apostrophes with 2 apostrophes needed for escaping in SQL -->
<xsl:variable name='comment'>
<xsl:call-template name="globalReplace">
<xsl:with-param name="outputString" select="$plaincomment"/>
<xsl:with-param name="target" select="$ap"/>
<xsl:with-param name="replacement" select="''"/>
</xsl:call-template>
</xsl:variable>
COMMENT ON TYPE <xsl:value-of select="refnamediv/refname" /> IS 'postgis type: <xsl:value-of select='$comment' />';
</xsl:when>
</xsl:choose>
</xsl:for-each>
<xsl:template match="sect1[contains(@id, 'Type')]">
<xsl:for-each select="refentry">
<xsl:variable name="ap"><xsl:text>'</xsl:text></xsl:variable>
<!-- If this is a raster type grab the ref entry summary and refname to make type comment -->
<xsl:variable name='plaincomment'>
<xsl:value-of select="normalize-space(translate(translate(refnamediv/refpurpose,'&#x0d;&#x0a;', ' '), '&#09;', ' '))"/>
</xsl:variable>
<!-- Replace apostrophes with 2 apostrophes needed for escaping in SQL -->
<xsl:variable name='comment'>
<xsl:call-template name="globalReplace">
<xsl:with-param name="outputString" select="$plaincomment"/>
<xsl:with-param name="target" select="$ap"/>
<xsl:with-param name="replacement" select="''"/>
</xsl:call-template>
</xsl:variable>
COMMENT ON TYPE <xsl:value-of select="refnamediv/refname" /> IS 'postgis raster type: <xsl:value-of select='$comment' />';
</xsl:for-each>
</xsl:template>
<!--General replace macro hack to make up for the fact xsl 1.0 does not have a built in one.