Changes between Version 33 and Version 34 of WKTRaster/SpecificationWorking01
- Timestamp:
- 10/07/09 14:02:53 (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
WKTRaster/SpecificationWorking01
v33 v34 112 112 == '''Objective 0.1.6d - Being able to get all the properties of a raster (all the “Get” functions).''' == 113 113 114 ''' RT_SRID(raster|geometry) -> integer'''[[BR]]114 '''ST_SRID(raster|geometry) -> integer'''[[BR]] 115 115 Return the SRID associated with the raster. 116 116 117 ''' RT_Width(raster) -> integer'''[[BR]]117 '''ST_Width(raster) -> integer'''[[BR]] 118 118 Return the width of the raster. 119 119 120 ''' RT_Height(raster) -> integer'''[[BR]]120 '''ST_Height(raster) -> integer'''[[BR]] 121 121 Return the height of the raster. 122 122 123 ''' RT_PixelSizeX(raster) -> float64'''[[BR]]123 '''ST_PixelSizeX(raster) -> float64'''[[BR]] 124 124 Return the georeference's X pixel size of the raster. [http://en.wikipedia.org/wiki/World_file See]. 125 125 126 ''' RT_PixelSizeY(raster) -> float64'''[[BR]]126 '''ST_PixelSizeY(raster) -> float64'''[[BR]] 127 127 Return the georeference's Y pixel size of the raster. [http://en.wikipedia.org/wiki/World_file See]. 128 128 129 ''' RT_RotationX(raster) -> float64'''[[BR]]129 '''ST_RotationX(raster) -> float64'''[[BR]] 130 130 Return the georeference's X rotation. 131 131 132 ''' RT_RotationY(raster) -> float64'''[[BR]]132 '''ST_RotationY(raster) -> float64'''[[BR]] 133 133 Return the georeference's Y rotation. [http://en.wikipedia.org/wiki/World_file See]. 134 134 135 ''' RT_UpperLeftX(raster) -> float64'''[[BR]]135 '''ST_UpperLeftX(raster) -> float64'''[[BR]] 136 136 Return the georeference's X-coordinate of the center of the upper left pixel. [http://en.wikipedia.org/wiki/World_file See]. 137 137 138 ''' RT_UpperLeftY(raster) -> float64'''[[BR]]138 '''ST_UpperLeftY(raster) -> float64'''[[BR]] 139 139 Return the georeference's Y-coordinate of the center of the upper left pixel. [http://en.wikipedia.org/wiki/World_file See]. 140 140 141 ''' RT_GeoReference(raster) -> string'''[[BR]]141 '''ST_GeoReference(raster) -> string'''[[BR]] 142 142 Return 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]. 143 143 144 ''' RT_NumBands(raster) -> integer'''[[BR]]144 '''ST_NumBands(raster) -> integer'''[[BR]] 145 145 Return the number of band included in the raster. 146 146 147 ''' RT_BandPixelType(raster, integer) -> string'''[[BR]]147 '''ST_BandPixelType(raster, integer) -> string'''[[BR]] 148 148 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: 149 149 * '''1BB''' - 1-bit boolean … … 160 160 * '''64BF''' - 64-bit float 161 161 162 ''' RT_BandNoDataValue(raster, integer) -> float32'''[[BR]]162 '''ST_BandNoDataValue(raster, integer) -> float32'''[[BR]] 163 163 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. 164 164 … … 166 166 == '''Objective 0.1.6e - Being able to intersect vector and raster to produce vector.''' == 167 167 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''' 174 174 175 175 ---- … … 177 177 == '''Objective 0.1.6f - Being able to return a JPEG, a TIFF or a PNG.''' == 178 178 179 ''' RT_bytea(raster, band) -> raster'''[[BR]]179 '''ST_bytea(raster, band) -> raster'''[[BR]] 180 180 What is does? 181 181 … … 183 183 '''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. 184 184 185 There is two options to select the band to convert from a multiband raster in all the RT_AsFormat functions. [[BR]]185 There is two options to select the band to convert from a multiband raster in all the ST_AsFormat functions. [[BR]] 186 186 [[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]] 188 188 Pros: This is a general function that can be called before any function that would otherwise require a band parameter.[[BR]] 189 189 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? 190 190 191 2. Add a band parameter to each RT_AsFormat function.[[BR]]191 2. Add a band parameter to each ST_AsFormat function.[[BR]] 192 192 Pros: Hypothetically less overhead.[[BR]] 193 193 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. … … 195 195 Pierre: More I think about it more I think that the first option is the best one... 196 196 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]]197 mloskot: 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]] 202 Return 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]] 205 205 Return 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) 206 206 … … 214 214 Pierre: 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. 215 215 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).216 Proposition 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). 217 217 218 218 Proposition two: There could also be just one parameter (string) defining a mapping method: … … 221 221 222 222 * 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)) 224 224 225 225 * 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.] 227 227 228 228 … … 239 239 ---- 240 240 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]] 242 Return 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 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. ST_AsTIFF(raster, "JPEG60") (copied from http://www.gdal.org/frmt_gtiff.html) 245 245 246 246 ---- 247 247 '''Open Question:''' What if we want to export only the first two band of a three band layer? 248 248 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"'''249 Maybe we need a ST_RasterFromBands(band1,band2,etc...) to reconstitute a multiband raster from multiple sources (having the same width, height, pixelsize, etc...) 250 251 mloskot: 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"''' 255 255 256 256 ---- … … 372 372 1. '''GiST indexing:''' is wrapping PostGIS Gist function in PL/PgSQL sufficient? From Paul comments it seems actually that cast are sufficients.[[BR]][[BR]] 373 373 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]] 376 376 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]] 378 378 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. 379 379 * 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]] 381 381 1. '''Architecture & design issues:'''[[BR]][[BR]] 382 382 * How to handle no NODATA? Pierre from Frank input: We'll need a !HasNoDataValue flag for each band.[[BR]][[BR]]