wiki:WKTRaster/SpecificationFinal01

Version 6 (modified by pracine, 15 years ago) ( diff )

PostGIS WKT Raster Beta 0.1 Final Specifications

Quick Links


Objective 0.1.6c - Being able to load rasters in the database

gdal2wktraster.py - A prototype of the translation utility implemented in Python and with use of GDAL and its bindings to Python. Create an SQL commands output to create a table of raster. As input raster file, all GDAL formats are accepted. The script is available as gdal2wktraster.py script.

USAGE:
gdal2wktraster.py -r rasterfile [-r rasterfile] -t [<schema>.]<table> [<options>]

-r <rasterfile> Specifies input raster file. Multiple -r options can be specified for a number of input files or wildcards can be used (? and *). At least one input raster file is REQUIRED.
-t <table> Name of destination table in with or without target schema specified. This parameter is REQUIRED.

OPTIONS:
-s <srid> Set the SRID field. Default is -1.
-b <nbband> Specify the number of band. The number of rasterfile must correspond to this number.
-f <field> Name of target column for raster data. Default column name is rast.
-I Create a GiST index on the raster column.
-o <file> Output file for generated SQL commands. If not specified, stdout is assumed.
-R Simply register the raster in the database. Absolute path to the raster and georeferencing informations are stored instead of the raster actual data.
-F Add a "filename" column containing the original name of the loaded raster file.

(-d|c) Mutually exclusive inserting options:

-d Drops the table, then recreates it and populates it with current raster file data.
-c Creates a new table and populates it, this is the default if you do not specify any options.

-v Switch on excessively verbose mode, useful for debugging.
-h Display this help screen.


Objective 0.1.6d - Being able to get all the properties of a raster (all the “Get” functions).

RT_SRID(raster|geometry) → integer
Return the SRID associated with the raster.

RT_Width(raster) → integer
Return the width of the raster.

RT_Height(raster) → integer
Return the height of the raster.

RT_PixelSizeX(raster) → float64
Return the georeference's X pixel size of the raster. See.

RT_PixelSizeY(raster) → float64
Return the georeference's Y pixel size of the raster. See.

RT_RotationX(raster) → float64
Return the georeference's X rotation.

RT_RotationY(raster) → float64
Return the georeference's Y rotation. See.

RT_UpperLeftX(raster) → float64
Return the georeference's X-coordinate of the center of the upper left pixel. See.

RT_UpperLeftY(raster) → float64
Return the georeference's Y-coordinate of the center of the upper left pixel. See.

RT_GeoReference(raster) → string
Return the georeference of the raster as a string representing the 6 doubles of an equivalent world file (including the carriage return). See.

RT_NumBands(raster) → integer
Return the number of band included in the raster.

RT_BandPixelType(raster, integer) → string
Return the pixel type of the specified 1-based Nth band of raster. Band index is 1-based. The function returns one of the following values:

  • 1BB - 1-bit boolean
  • 2BUI - 2-bit unsigned integer
  • 4BUI - 4-bit unsigned integer
  • 8BSI - 8-bit signed integer
  • 8BUI - 8-bit unsigned integer
  • 16BSI - 16-bit signed integer
  • 16BUI - 16-bit unsigned integer
  • 32BSI - 32-bit signed integer
  • 32BUI - 32-bit unsigned integer
  • 16BF - 16-bit float
  • 32BF - 32-bit float
  • 64BF - 64-bit float

RT_BandNoDataValue(raster, integer) → float32
Return the NoDataValue of the specified 1-based Nth band of raster. Band index is 1-based. The value is always returned as a float32 even if the pixel type is integer.


RASTER_COLUMNS Metadata Table

The following metadata table provides external applications and possibly internal tools the ability to discover tables with raster data, and to learn various information about those datasets.

Column Name Type Constraints Comments
r_table_catalog character varying(256) NOT NULL
r_table_schema character varying(256) NOT NULL
r_table_name character varying(256) NOT NULL
r_column character varying(256) NOT NULL
srid integer NOT NULL Use 0 for unknown SRID
pixel_types ARRAY=VARCHAR= NOT NULL an array of pixeltypes, one per band. The band count is implicit in the size of this array.
out_db boolean NOT NULL false if internal tiles, true if tiles are references to files outside the database
regular_blocking boolean NOT NULL false by default, true if all blocks are equal sized, abutted and non-overlapping, started at top left origin (see below)
nodata_values ARRAY=DOUBLE= an array of nodata values, one per band. The entry may be NULL to indicate no nodata values.
pixelsize_x double width of a pixel in geounits (per SRID)
pixelsize_y double height of a pixel in geounits (per SRID)
blocksize_x integer the width of a block in pixels (NULL if irregular)
blocksize_y integer the height of a block in pixels (NULL if irregular)
extent GEOMETRY a polygon geometry containing all raster tiles, or NULL if predefined bounds are not known. For "regular_blocking" cases this geometry will be a simple rectangle. In other cases it might be an irregular polygon.

If the regular_blocking field is true a number of restrictions are placed on the raster column that is defined:

  1. All tiles must have the same size (blocksize_x and blocksize_y).
  2. All tiles must be non-overlapping, and appear on regular block grid.
  3. The top left block must start at the top left corner of the extent.
  4. The right most column, and bottom row of blocks may have portions that extend beyond the raster extent. These areas will be assumed to be nodata and not part of the described raster.
  5. The extent field must be a simple rectangle (non-rotated).

It is permissable to for regular_blocking rasters to omit some blocks/tiles (sparse rasters) in which case the missing tiles should be assumed to be all nodata or zero valued.


Attachments (2)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.