Changes between Version 33 and Version 34 of WKTRaster/SpecificationWorking01


Ignore:
Timestamp:
Oct 7, 2009, 2:02:53 PM (15 years ago)
Author:
pracine
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • WKTRaster/SpecificationWorking01

    v33 v34  
    112112== '''Objective 0.1.6d - Being able to get all the properties of a raster (all the “Get” functions).''' ==
    113113
    114 '''RT_SRID(raster|geometry) -> integer'''[[BR]]
     114'''ST_SRID(raster|geometry) -> integer'''[[BR]]
    115115Return the SRID associated with the raster.
    116116
    117 '''RT_Width(raster) -> integer'''[[BR]]
     117'''ST_Width(raster) -> integer'''[[BR]]
    118118Return the width of the raster.
    119119
    120 '''RT_Height(raster) -> integer'''[[BR]]
     120'''ST_Height(raster) -> integer'''[[BR]]
    121121Return the height of the raster.
    122122
    123 '''RT_PixelSizeX(raster) -> float64'''[[BR]]
     123'''ST_PixelSizeX(raster) -> float64'''[[BR]]
    124124Return the georeference's X pixel size of the raster. [http://en.wikipedia.org/wiki/World_file See].
    125125
    126 '''RT_PixelSizeY(raster) -> float64'''[[BR]]
     126'''ST_PixelSizeY(raster) -> float64'''[[BR]]
    127127Return the georeference's Y pixel size of the raster. [http://en.wikipedia.org/wiki/World_file See].
    128128
    129 '''RT_RotationX(raster) -> float64'''[[BR]]
     129'''ST_RotationX(raster) -> float64'''[[BR]]
    130130Return the georeference's X rotation.
    131131
    132 '''RT_RotationY(raster) -> float64'''[[BR]]
     132'''ST_RotationY(raster) -> float64'''[[BR]]
    133133Return the georeference's Y rotation. [http://en.wikipedia.org/wiki/World_file See].
    134134
    135 '''RT_UpperLeftX(raster) -> float64'''[[BR]]
     135'''ST_UpperLeftX(raster) -> float64'''[[BR]]
    136136Return the georeference's X-coordinate of the center of the upper left pixel. [http://en.wikipedia.org/wiki/World_file See].
    137137
    138 '''RT_UpperLeftY(raster) -> float64'''[[BR]]
     138'''ST_UpperLeftY(raster) -> float64'''[[BR]]
    139139Return the georeference's Y-coordinate of the center of the upper left pixel. [http://en.wikipedia.org/wiki/World_file See].
    140140
    141 '''RT_GeoReference(raster) -> string'''[[BR]]
     141'''ST_GeoReference(raster) -> string'''[[BR]]
    142142Return the georeference of the raster as a string representing the 6 doubles of an equivalent world file (including the carriage return). [http://en.wikipedia.org/wiki/World_file See].
    143143
    144 '''RT_NumBands(raster) -> integer'''[[BR]]
     144'''ST_NumBands(raster) -> integer'''[[BR]]
    145145Return the number of band included in the raster.
    146146
    147 '''RT_BandPixelType(raster, integer) -> string'''[[BR]]
     147'''ST_BandPixelType(raster, integer) -> string'''[[BR]]
    148148Return 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:
    149149  * '''1BB''' - 1-bit boolean
     
    160160  * '''64BF''' - 64-bit float
    161161
    162 '''RT_BandNoDataValue(raster, integer) -> float32'''[[BR]]
     162'''ST_BandNoDataValue(raster, integer) -> float32'''[[BR]]
    163163Return 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.
    164164
     
    166166== '''Objective 0.1.6e - Being able to intersect vector and raster to produce vector.''' ==
    167167 
    168 '''RT_GetBBox(raster) -> polygon geometry'''[[BR]]
    169 '''RT_Envelope(raster|geometry) -> polygon geometry'''[[BR]]
    170 '''RT_Shape(raster) -> polygon geometry'''[[BR]]
    171 '''RT_AsPolygon(raster) -> polygon geometry set'''[[BR]]
    172 '''RT_Intersects(raster|geometry, raster|geometry)'''[[BR]]
    173 '''RT_Intersection(raster|geometry, raster|geometry, ‘raster’|’geometry’)->raster/geometry'''
     168'''ST_GetBBox(raster) -> polygon geometry'''[[BR]]
     169'''ST_Envelope(raster|geometry) -> polygon geometry'''[[BR]]
     170'''ST_Shape(raster) -> polygon geometry'''[[BR]]
     171'''ST_AsPolygon(raster) -> polygon geometry set'''[[BR]]
     172'''ST_Intersects(raster|geometry, raster|geometry)'''[[BR]]
     173'''ST_Intersection(raster|geometry, raster|geometry, ‘raster’|’geometry’)->raster/geometry'''
    174174
    175175----
     
    177177== '''Objective 0.1.6f - Being able to return a JPEG, a TIFF or a PNG.''' ==
    178178 
    179 '''RT_bytea(raster, band) -> raster'''[[BR]]
     179'''ST_bytea(raster, band) -> raster'''[[BR]]
    180180What is does?
    181181
     
    183183'''Open Question:''' When exporting a multiband raster to JPEG, TIFF, PNG, SVG or KML, how should we specify the band number in the exporting function.
    184184
    185 There is two options to select the band to convert from a multiband raster in all the RT_AsFormat functions. [[BR]]
     185There is two options to select the band to convert from a multiband raster in all the ST_AsFormat functions. [[BR]]
    186186[[BR]]
    187  1. Precede each call with RT_Band() to return a selected band.[[BR]]
     187 1. Precede each call with ST_Band() to return a selected band.[[BR]]
    188188  Pros: This is a general function that can be called before any function that would otherwise require a band parameter.[[BR]]
    189189  Cons: This implies creating a temporary raster. This might be more elegant and general but is this too much overhead comparing with having a band parameter?
    190190
    191  2. Add a band parameter to each RT_AsFormat function.[[BR]]
     191 2. Add a band parameter to each ST_AsFormat function.[[BR]]
    192192  Pros: Hypothetically less overhead.[[BR]]
    193193  Cons: Every functions implying access to a band should then have this parameter when in most case it would be equal to 1. In many cases it makes no sence to have to specify a band parameter since it is the whole raster that we want to export, including all the bands.
     
    195195Pierre: More I think about it more I think that the first option is the best one...
    196196
    197 mloskot: Perhaps there is a compromise in form of two sets of functions: 1) RT_As* which always burn the whole raster (all bands) 2) RT_BandAs* which takes number of band as a parameter and return only this requested band.
    198 
    199 ----
    200 
    201 '''RT_Band(raster, band) -> raster'''[[BR]]
    202 Return a single band from a multiband raster. If "band" is greater than the value returned by RT_GetNumBands(), the function returns the last band. This function should be used to select a band before converting it to JPEG, TIFF, PNG, SVG or KML with the corresponding function. e.g. '''RT_AsJPEG(RT_Band(raster, band), quality)
    203 
    204 '''RT_AsJPEG(raster, quality) -> JPEG as "bytea"'''[[BR]]
     197mloskot: Perhaps there is a compromise in form of two sets of functions: 1) ST_As* which always burn the whole raster (all bands) 2) ST_BandAs* which takes number of band as a parameter and return only this requested band.
     198
     199----
     200
     201'''ST_Band(raster, band) -> raster'''[[BR]]
     202Return a single band from a multiband raster. If "band" is greater than the value returned by ST_GetNumBands(), the function returns the last band. This function should be used to select a band before converting it to JPEG, TIFF, PNG, SVG or KML with the corresponding function. e.g. '''ST_AsJPEG(ST_Band(raster, band), quality)
     203
     204'''ST_AsJPEG(raster, quality) -> JPEG as "bytea"'''[[BR]]
    205205Return the raster as a JPEG encoded as a PostgreSQL bytea. By default quality is set to 75, but this option can be used to select other values. Values must be in the range 10-100. Low values result in higher compression ratios, but poorer image quality. Values above 95 are not meaningfully better quality but can but substantially larger. (copied from http://www.gdal.org/frmt_jpeg.html)
    206206
     
    214214Pierre: It might be more simple to ignore pixeltypes other than 8BUI but it would be very convenient to have a way to quickly export elevation data for example as a JPEG. It would be nice to have an elegant solution to this. Maybe something inspired from MapServer.
    215215
    216 Proposition one (Pierre): RT_AsJPEG could simply (optionally when the pixeltype is not 8BUI) map the RT_Maximum() and RT_Minimum() value to 0-255. RT_Maximum() and RT_Minimum() are not in the spec yet but this could be on nice usage of it. They will imply caching the min and max when importing and editing. Both function should ignore the !NoDataValues. They could also be two parameters passed to RT_AsJPEG(raster, quality, min, max).
     216Proposition one (Pierre): ST_AsJPEG could simply (optionally when the pixeltype is not 8BUI) map the ST_Maximum() and ST_Minimum() value to 0-255. ST_Maximum() and ST_Minimum() are not in the spec yet but this could be on nice usage of it. They will imply caching the min and max when importing and editing. Both function should ignore the !NoDataValues. They could also be two parameters passed to ST_AsJPEG(raster, quality, min, max).
    217217
    218218Proposition two: There could also be just one parameter (string) defining a mapping method:
     
    221221
    222222 * Method "!MaxMinValue": Use the Max and the Min cached in the raster. e.g. for 16BSI (min, max) -> (-2033, 2456) -> (round((-2033 - -2033)/(2456 - -2033)*255), round((2456 - -2033)/(2456 - -2033)*255)) -> (0, 255).[[BR]]
    223 [[BR]]This is equivalent to RT_AsJPEG(raster, quality, RT_Minimum(rast), RT_Maximum(rast))
     223[[BR]]This is equivalent to ST_AsJPEG(raster, quality, ST_Minimum(rast), ST_Maximum(rast))
    224224
    225225 * Method "!MaxMinType": Use the Max and the Min allowed by the type. e.g. for 16BSI (min, max) -> (-2033, 2456) -> (round((-2033 - -32768)/(32767 - -32768)*255), round((2456 - -32768)/(32767 - -32768)*255)) -> (120, 137)[[BR]]
    226 [[BR]]This would be equivalent to RT_AsJPEG(raster, quality, RT_BandPixelTypeMin(rast), RT_BandPixelTypeMax(rast)). Both functions (RT_BandPixelTypeMin & RT_BandPixelTypeMax) are not yet planned and I could not find an SQL query that returns the equivalent range for a type. [http://groups.google.nl/group/microsoft.public.sqlserver.programming/browse_thread/thread/46512c2691da4607/6743f4aea485c6d1 One possible solution.]
     226[[BR]]This would be equivalent to ST_AsJPEG(raster, quality, ST_BandPixelTypeMin(rast), ST_BandPixelTypeMax(rast)). Both functions (ST_BandPixelTypeMin & ST_BandPixelTypeMax) are not yet planned and I could not find an SQL query that returns the equivalent range for a type. [http://groups.google.nl/group/microsoft.public.sqlserver.programming/browse_thread/thread/46512c2691da4607/6743f4aea485c6d1 One possible solution.]
    227227
    228228
     
    239239----
    240240
    241 '''RT_AsTIFF(raster, compression) -> TIFF as "bytea"'''[[BR]]
    242 Return the raster as a JPEG encoded as a PostgreSQL bytea. If raster is a multiband raster and no band were selected with RT_Band() every band are written to the resulting TIFF.
    243 
    244 compression=[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. RT_AsTIFF(raster, "JPEG60") (copied from http://www.gdal.org/frmt_gtiff.html)
     241'''ST_AsTIFF(raster, compression) -> TIFF as "bytea"'''[[BR]]
     242Return the raster as a JPEG encoded as a PostgreSQL bytea. If raster is a multiband raster and no band were selected with ST_Band() every band are written to the resulting TIFF.
     243
     244compression=[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)
    245245
    246246----
    247247'''Open Question:''' What if we want to export only the first two band of a three band layer?
    248248
    249 Maybe we need a RT_RasterFromBands(band1,band2,etc...) to reconstitute a multiband raster from multiple sources (having the same width, height, pixelsize, etc...)
    250 
    251 mloskot: or RT_RasterFromBands(bands) where bands is ARRAY[int]. For instance, RT_RasterFromBands(ARRAY[1,3]) will burn new raster from 1 and 3 bands of input raster.
    252 
    253 ----
    254 '''RT_AsPNG(raster, band) -> PNG as "bytea"'''
     249Maybe we need a ST_RasterFromBands(band1,band2,etc...) to reconstitute a multiband raster from multiple sources (having the same width, height, pixelsize, etc...)
     250
     251mloskot: or ST_RasterFromBands(bands) where bands is ARRAY[int]. For instance, ST_RasterFromBands(ARRAY[1,3]) will burn new raster from 1 and 3 bands of input raster.
     252
     253----
     254'''ST_AsPNG(raster, band) -> PNG as "bytea"'''
    255255
    256256----
     
    372372 1. '''GiST indexing:''' is wrapping PostGIS Gist function in PL/PgSQL sufficient? From Paul comments it seems actually that cast are sufficients.[[BR]][[BR]]
    373373 1. '''API:''' Any other SQL raster function you would like to see?[[BR]][[BR]]
    374   a. ML: RT_AsJPEG - What JPEG implementation to use?[[BR]][[BR]]
    375   a. ML: RT_AsTIFF - Do we aim to depend on libgeotiff?[[BR]][[BR]]
     374  a. ML: ST_AsJPEG - What JPEG implementation to use?[[BR]][[BR]]
     375  a. ML: ST_AsTIFF - Do we aim to depend on libgeotiff?[[BR]][[BR]]
    376376  a. ML: Is there any function that would require/fit GDAL dependency?[[BR]][[BR]]
    377   a. Pierre: We should maybe investigate the cost of using GDAL and have a general RT_AsImage(format, params) instead of using the individual tiff, jpeg and png libraries. Those will anyway also have a cost I guess... And we will probably have to link with GDAL for AsPolygon(rast) and AsRaster(geom) anyway.[[BR]][[BR]]
     377  a. Pierre: We should maybe investigate the cost of using GDAL and have a general ST_AsImage(format, params) instead of using the individual tiff, jpeg and png libraries. Those will anyway also have a cost I guess... And we will probably have to link with GDAL for AsPolygon(rast) and AsRaster(geom) anyway.[[BR]][[BR]]
    378378 1. '''Implementing raster -> vector conversion for intersections().''' How to do it? Possible using only plpgsql? So we don't have to link with liblwgeos and we can have our own release schedule.
    379379   * polygonize with GDAL or GRASS, that generates some internal structure for those libraries, and you turn that into a WKT form of polygon. That can be passed to PostGIS, and you don't need to link to liblwgeom.[[BR]][[BR]]
    380  1. '''Best practice for band referencing:''' having a band parameter (index?) or always use RT_Band()[[BR]][[BR]]-e.g. SELECT RT_AsTIFF(RT_Band(raster,2),60) FROM coverandtemp[[BR]][[BR]]SELECT RT_AsTIFF(RT_Band(raster,2),RT_Band(raster,1),60) FROM coverandtemp[[BR]]or[[BR]]SELECT RT_AsTIFF(raster,2,60) FROM coverandtemp[[BR]][[BR]]Pierre: Having a band parameter (or a list of band) for each function trying to access a band would be preferable to avoid useless memcopy of band data.[[BR]][[BR]]
     380 1. '''Best practice for band referencing:''' having a band parameter (index?) or always use ST_Band()[[BR]][[BR]]-e.g. SELECT ST_AsTIFF(ST_Band(raster,2),60) FROM coverandtemp[[BR]][[BR]]SELECT ST_AsTIFF(ST_Band(raster,2),ST_Band(raster,1),60) FROM coverandtemp[[BR]]or[[BR]]SELECT ST_AsTIFF(raster,2,60) FROM coverandtemp[[BR]][[BR]]Pierre: Having a band parameter (or a list of band) for each function trying to access a band would be preferable to avoid useless memcopy of band data.[[BR]][[BR]]
    381381 1. '''Architecture & design issues:'''[[BR]][[BR]]
    382382   * How to handle no NODATA? Pierre from Frank input: We'll need a !HasNoDataValue flag for each band.[[BR]][[BR]]