concept row in category postgis

appears as: rows, row, row, rows
PostGIS in Action, Third Edition

This is an excerpt from Manning's book PostGIS in Action, Third Edition.

Pixels are organized in rows and columns to form tiles. To make life easier, all tiles should be rectangular. When we speak of the size of a raster tile, we’re referring to the number of horizontal pixels and vertical pixels. For example, your 1080p HDTV can be said to have 1920 columns and 1080 rows of pixels, a 1920✕1080 raster tile, giving you a total count of 2.1 megapixels. Remember that pixels are positional designations, not data. The actual data elements rest in bands (sometimes known as channels or dimensions). On your RGB TV raster, you can have three bands of data—one for each of the primary colors. PostGIS rasters can have as many as 255 bands in PostGIS 2.0, and even more in later versions.

Listing 14.12. Instead of trigger on a view
CREATE OR REPLACE FUNCTION trig_subway_insert()
  RETURNS trigger AS  #1
$$
BEGIN
    INSERT INTO ch14.paris_points (
        gid, osm_id, ar_num, feature_name, feature_type, geom
    )
    VALUES (
        DEFAULT,
        NEW.osm_id,
        COALESCE(NEW.ar_num,
                 (SELECT a.ar_num
                    FROM ch14.arrondissements AS a
                  WHERE ST_Intersects(NEW.geom, a.geom )) ) ,
        NEW.feature_name,
        'subway',
        NEW.geom
    );
    RETURN NEW;
END;
  $$ language plpgsql;

CREATE TRIGGER t01_trig_subway_insert #2
  INSTEAD OF INSERT
  ON ch14.subways
  FOR EACH ROW
  EXECUTE PROCEDURE trig_subway_insert();
  • In the definition of a calculated column — When used in this context, the subselect can return only one column and one row. This pretty much applies to all databases, but PostgreSQL has a somewhat unique feature because of the way it implements rows. Each table has a data type that contains all the columns of its row. As such, a table can be used as a data type of a column. In addition, a row, even one coming from a subselect, is a composite type. This allows you to get away with returning a multicolumn row as a field expression. This isn’t a feature you’ll commonly find in other databases, so we won’t cover it in this appendix. You can, however, return multiple rows as an array if they contain only one column by using ARRAY in PostgreSQL. This will return the column as an array of that type. We demonstrate this in various parts of the book. Again, this is a feature that’s fairly unique to PostgreSQL and is very handy for spatial queries. There is a feature called "Computed columns", which was introduced in PostgreSQL 12 and allows you to define a formula as a column in a table. The caveate is the column can only reference values in the particular row. This is defined at the Data Definition Level (DDL), not Data Manipulation Level (DML).