Changes between Version 59 and Version 60 of WKTRaster/SpecificationWorking03


Ignore:
Timestamp:
Apr 10, 2011, 10:14:04 AM (13 years ago)
Author:
Bborie Park
Comment:

ST_TIFF functions

Legend:

Unmodified
Added
Removed
Modified
  • WKTRaster/SpecificationWorking03

    v59 v60  
    186186
    187187compression=[JPEG/LZW/PACKBITS/DEFLATE/CCITTRLE/CCITTFAX3/CCITTFAX4/NONE]: Set the type of compression to use. None is the default. The CCITT compression should only be used with 1bit (NBITS=1) data. JPEG should only be used with Byte data. When using JPEG add a number specifying the quality. 75 is the default. e.g. ST_AsTIFF(raster, "JPEG60") (copied from http://www.gdal.org/frmt_gtiff.html)
     188
     189Bborie: A proposed implementation of the ST_AsTIFF functions.
     190
     191The TIFF format is probably the most robust available for converting rasters to GDAL rasters. Not only does it support all PostGIS Raster pixel types, it also provides plenty of creation options and possibly no issues with the number of bands. The only limitation found is that there can only be one NODATA value for all bands.
     192
     193The next three functions are the most basic of the ST_AsTIFF functions.
     194
     1951. ST_AsTIFF(rast raster, options text[], srs text) -> bytea
     196
     197    The most generic version of this function. All other ST_AsTIFF functions call this function.
     198
     199    This function will check that all bands of the raster to be converted has the same NODATA value. If there are more than one possible NODATA values, a WARNING will be raised and the output TIFF will use the NODATA value of the last band with a NODATA value.
     200
     201        options: the GDAL creation options found in the Creation Options section of the GDAL TIFF driver
     202
     203        srs: the user-specified OGC WKT or the proj4 text for a spatial reference to embed in the GDAL raster. TIFF is one of the formats that supports embedding the spatial reference within the image file.
     204
     205{{{
     206ST_AsTIFF(rast, ARRAY['COMPRESS=DEFLATE', 'ZLEVEL=9'], '+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs')
     207
     208ST_AsTIFF(rast, ARRAY['COMPRESS=DEFLATE', 'ZLEVEL=9'], 'PROJCS["NAD83 / California Albers",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Albers_Conic_Equal_Area"],PARAMETER["standard_parallel_1",34],PARAMETER["standard_parallel_2",40.5],PARAMETER["latitude_of_center",0],PARAMETER["longitude_of_center",-120],PARAMETER["false_easting",0],PARAMETER["false_northing",-4000000],AUTHORITY["EPSG","3310"],AXIS["X",EAST],AXIS["Y",NORTH]]')
     209}}}
     210
     2112. ST_AsTIFF(rast raster, options text[]) -> bytea
     212
     213This one removes the user-specified srs argument. The output TIFF's spatial reference will be set to the same as the input raster, if possible.
     214
     215{{{
     216ST_AsTIFF(rast, ARRAY['COMPRESS=DEFLATE', 'ZLEVEL=9'])
     217}}}
     218
     2193. ST_AsTIFF(rast raster) -> bytea
     220
     221The simplest implementation of this function. Since the options argument has been removed, the output TIFF will be created with default options. Like the prior function, the spatial reference of the TIFF will be set to the same as the input raster.
     222
     223{{{
     224ST_AsTIFF(rast)
     225}}}
     226
     227
     228The next three functions add a band index argument to filter the raster's bands before generating the output TIFF.
     229
     2304. ST_AsTIFF(rast raster, nbands int[], options text[], srs text) -> bytea
     231
     232{{{
     233ST_AsTIFF(rast, ARRAY[3,1,2], ARRAY['COMPRESS=DEFLATE', 'ZLEVEL=9'], '+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs')
     234}}}
     235
     2365. ST_AsTIFF(rast raster, nbands int[], options text[]) -> bytea
     237
     238This one removes the user-specified srs argument. The output TIFF's spatial reference will be set to the same as the input raster, if possible.
     239
     240{{{
     241ST_AsTIFF(rast, ARRAY[3,1,2], ARRAY['COMPRESS=DEFLATE', 'ZLEVEL=9'])
     242}}}
     243
     2446. ST_AsTIFF(rast raster, nbands int[]) -> bytea
     245
     246Since the options argument has been removed, the output TIFF will be created with default options. Like the prior function, the spatial reference of the TIFF will be set to the same as the input raster.
     247
     248{{{
     249ST_AsTIFF(rast, ARRAY[3,1,2])
     250}}}
     251
     252
     253The next two functions add a compression argument. If the compression desired is JPEG or DEFLATE, the user can specify a quality as part of the compression string.
     254
     255Examples are:
     256
     257{{{
     258JPEG90
     259
     260JPEG
     261
     262DEFLATE8
     263
     264DEFLATE
     265}}}
     266
     2677. ST_AsTIFF(rast raster, compression text, srs text) -> bytea
     268
     269This function will parse the compression string for the compression type and the compression quality. It will also inspect to make sure that the pixel types of the raster's bands are appropriate for the compression type. This is primarily for JPEG and CCITT compression types, which only support 8BUI and 1BB respectively.
     270
     271{{{
     272ST_AsTIFF(rast, 'JPEG90', '+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs')
     273
     274ST_AsTIFF(rast, 'JPEG', '+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs')
     275
     276ST_AsTIFF(rast, 'LZMA', '+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs')
     277}}}
     278
     2798. ST_AsTIFF(rast raster, compression text) -> bytea
     280
     281The output TIFF will be created with default options. Like the prior function, the spatial reference of the TIFF will be set to the same as the input raster.
     282
     283{{{
     284ST_AsTIFF(rast, 'LZMA')
     285}}}
     286
     287
     288The next two functions include band index and compression arguments
     289
     2909. ST_AsTIFF(rast raster, nbands int[], compression text, srs text) -> bytea
     291
     292{{{
     293ST_AsTIFF(rast, ARRAY[2], 'JPEG90', ARRAY['BIGTIFF=IF_NEEDED'], '+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs')
     294
     295ST_AsTIFF(rast, ARRAY[1,3], 'JPEG', ARRAY['BIGTIFF=IF_NEEDED'], '+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs')
     296
     297ST_AsTIFF(rast, ARRAY[3,1,2], 'LZMA', ARRAY['BIGTIFF=IF_NEEDED'], '+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs')
     298}}}
     299
     30010. ST_AsTIFF(rast raster, nbands int[], compression text) -> bytea
     301
     302{{{
     303ST_AsTIFF(rast, ARRAY[3,2], 'DEFLATE9')
     304}}}
     305
     306The output TIFF will be created with default options. The spatial reference of the TIFF will be set to the same as the input raster.
    188307
    189308----