403 | | '''ST_Resample(raster, method, originx, originy, pixelsizex, pixelsizey) -> raster''' |
404 | | |
405 | | * Implemented as a wrapper around GDAL like done for ST_DumpAsPolygons() |
406 | | * Resampling methods are the same as the one priovided by GDAL |
407 | | |
408 | | '''Variants''' |
409 | | |
410 | | * The '''first series of variants''' only change the pixelsize of the raster. |
411 | | |
412 | | 1) ST_Resample(raster, pixelsize) - modify pixelsize only and resample using the default method |
413 | | |
414 | | 2) ST_Resample(raster, method, pixelsize) - modify pixelsize and resample using the specified method |
415 | | |
416 | | 3) ST_Resample(raster, pixelsizex, pixelsizey) - modify pixelsize with different values for x and y using the default method |
417 | | |
418 | | 4) ST_Resample(raster, method, pixelsizex, pixelsizey) - modify pixelsize with different values for x and y using the specified method |
419 | | |
420 | | * The '''second series of variants''' realign the raster and change the pixelsize |
421 | | |
422 | | 5) ST_Resample(raster, x, y, pixelsize) - realign and modify pixelsize using the default method |
423 | | |
424 | | 6) ST_Resample(raster, method, x, y, pixelsize) - realign and modify pixelsize using the specified method |
425 | | |
426 | | 7) ST_Resample(raster, x, y, pixelsizex, pixelsizey) - realign and modify pixelsize with different values for x and y using the default method |
427 | | |
428 | | 8) ST_Resample(raster, method, x, y, pixelsizex, pixelsizey) - realign and modify pixelsize with different values for x and y using the specified method |
429 | | |
430 | | 9) ST_Resample(raster, x, y, pixelsizex, pixelsizey, skewx, skewy) - realign and modify pixelsize and skew with different values for x and y using the default method |
431 | | |
432 | | 10) ST_Resample(raster, method, x, y, pixelsizex, pixelsizey, skewx, skewy) - realign and modify pixelsize and skew with different values for x and y using the specified method |
433 | | |
434 | | * The '''third series of variants''' align and resample the raster to match the alignment, pixelsize and skew of an existing raster. |
435 | | |
436 | | 11) ST_Resample(destraster, sourceraster) |
437 | | |
438 | | '''Questions''' |
439 | | |
440 | | * Should there be a band parameter? |
441 | | * How does GDAL allow resampling? |
442 | | * Which methods GDAL supports? ArcGIS supports NEAREST | BILINEAR | CUBIC | MAJORITY |
443 | | * Does GDAL support change in skew? |
| 403 | '''ST_Resample(raster, method, originx, originy, pixelsizex, pixelsizey) -> raster - done see below''' |
| 3205 | |
| 3206 | ---- |
| 3207 | |
| 3208 | '''ST_Resample(raster, method, originx, originy, pixelsizex, pixelsizey) -> raster''' |
| 3209 | |
| 3210 | ST_Resample is the main function underlying the ST_Transform, ST_Rescale, ST_Reskew and ST_SnapToGrid functions. ST_Resample provides the ability to change a raster's projection, adjust the scale of the raster within its extent, change the skew (or deskew) and "dissolve" the raster to a grid. |
| 3211 | |
| 3212 | ''If a skewed raster is provided to ST_Resample and skewx and/or skewy are not provided, the output raster will be deskewed (zero skew in X and Y axes thus "north up")'' |
| 3213 | |
| 3214 | 1. ST_Resample( |
| 3215 | rast raster, |
| 3216 | srid integer DEFAULT NULL, |
| 3217 | scalex double precision DEFAULT 0, scaley double precision DEFAULT 0, |
| 3218 | gridx double precision DEFAULT NULL, gridy double precision DEFAULT NULL, |
| 3219 | skewx double precision DEFAULT 0, skewy double precision DEFAULT 0, |
| 3220 | algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125 |
| 3221 | ) -> raster |
| 3222 | |
| 3223 | srid: the SRID that the function will use to reproject the raster to. If NULL, the raster's SRID will be used. |
| 3224 | |
| 3225 | scalex: the scale/pixel size in the X axis of the resampled raster. If scalex and scaley are zero (0), the resampled raster's scale will be autocomputed. If provided, scaley must also be provided. |
| 3226 | |
| 3227 | scaley: the scale/pixel size in the Y axis of the resampled raster. If scalex and scaley are zero (0), the resampled raster's scale will be autocomputed. If provided, scalex must also be provided. |
| 3228 | |
| 3229 | gridx: the X coordinate of a point on the grid to which the raster will be aligned. Value is in the resampled raster's world coordinates. If provided, gridy must also be provided. |
| 3230 | |
| 3231 | gridy: the Y coordinate of a point on the grid to which the raster will be aligned. Value is in the resampled raster's world coordinates. If provided, gridx must also be provided. |
| 3232 | |
| 3233 | skewx: the skew along the X axis of the resampled raster. If skewx and skewy are zero (0), the resampled raster will be "north up". |
| 3234 | |
| 3235 | skewy: the skew along the Y axis of the resampled raster. If skewx and skewy are zero (0), the resampled raster will be "north up". |
| 3236 | |
| 3237 | algorithm: the algorithm to use when resampling the raster. default is 'NearestNeighbour'. possible algorithms are: |
| 3238 | |
| 3239 | {{{ |
| 3240 | NearestNeighbour (default. fastest performance but worst interpolation) |
| 3241 | |
| 3242 | NearestNeighbor (for those wanting to use the American spelling) |
| 3243 | |
| 3244 | Bilinear |
| 3245 | |
| 3246 | Cubic |
| 3247 | |
| 3248 | CubicSpline |
| 3249 | |
| 3250 | Lanczos |
| 3251 | }}} |
| 3252 | |
| 3253 | maxerr: the threshold for approximation by the resampling algorithm (in pixel units). default is 0.125, which is the same value used in GDAL gdalwarp utility. if set to zero, no approximation takes place. |
| 3254 | |
| 3255 | 2. ST_Resample( |
| 3256 | rast raster, |
| 3257 | ref raster, |
| 3258 | algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125 |
| 3259 | ) -> raster |
| 3260 | |
| 3261 | ref: the reference raster to which rast will copy the scalex, scaley, skewx, skewy and srid. In addition, the upperleft corner of ref will be used as a grid point to align rast. |
| 3262 | |
| 3263 | ---- |
| 3264 | |
| 3265 | '''ST_Rescale(raster, scalex, scaley) -> raster''' |
| 3266 | |
| 3267 | ST_Rescale is a focused function of ST_Resample for changing the X and Y scale without affecting the extent of the raster. |
| 3268 | |
| 3269 | ''If a skewed raster is provided to ST_Rescale, the output raster will be deskewed (zero skew in X and Y axes thus "north up"). To preserve the skew, use ST_Resample.'' |
| 3270 | |
| 3271 | 1. ST_Rescale(rast raster, scalex double precision, scaley double precision, algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125) -> raster |
| 3272 | |
| 3273 | scalex: the scale/pixel size in the X axis of the resampled raster |
| 3274 | |
| 3275 | scaley: the scale/pixel size in the Y axis of the resampled raster |
| 3276 | |
| 3277 | 2. ST_Rescale(rast raster, scalexy double precision, algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125) -> raster |
| 3278 | |
| 3279 | scalexy: the scale/pixel size in the X and Y axes of the resampled raster. |
| 3280 | |
| 3281 | ---- |
| 3282 | |
| 3283 | '''ST_Reskew(raster, skewx, skewy) -> raster''' |
| 3284 | |
| 3285 | ST_Reskew is a focused function of ST_Resample for changing the skew along the X and Y axes. |
| 3286 | |
| 3287 | 1. ST_Reskew(rast raster, skewx double precision, skewy double precision, algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125) -> raster |
| 3288 | |
| 3289 | skewx: the skew along the X axis of the resampled raster. If skewx and skewy are zero (0), the resampled raster will be "north up". |
| 3290 | |
| 3291 | skewy: the skew along the Y axis of the resampled raster. If skewx and skewy are zero (0), the resampled raster will be "north up". |
| 3292 | |
| 3293 | 2. ST_Reskew(rast raster, skewxy double precision, algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125) -> raster |
| 3294 | |
| 3295 | skewxy: the skew along both X and Y axes of the resampled raster. If skewxy is zero (0), the resampled raster will be "north up". |
| 3296 | |
| 3297 | ---- |
| 3298 | |
| 3299 | '''ST_SnapToGrid(raster, gridx, gridy)''' |
| 3300 | |
| 3301 | ST_SnapToGrid provides the ability to align a raster to grid (possibly that of a coverage). The returned raster has its upper-left corner placed at the closest valid grid point to the source raster's upper-left corner without losing a data. The same is done for the lower-right corner. |
| 3302 | |
| 3303 | ''If a skewed raster is provided to ST_SnapToGrid, the output raster will be deskewed (zero skew in X and Y axes thus "north up"). To preserve the skew, use ST_Resample.'' |
| 3304 | |
| 3305 | 1. ST_SnapToGrid( |
| 3306 | rast raster, |
| 3307 | gridx double precision, gridy double precision, |
| 3308 | algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125, |
| 3309 | scalex double precision DEFAULT 0, scaley double precision DEFAULT 0 |
| 3310 | ) -> raster |
| 3311 | |
| 3312 | gridx: the X coordinate of a point on the grid to which the raster will be aligned. Value is in the raster's world coordinates. |
| 3313 | |
| 3314 | gridy: the Y coordinate of a point on the grid to which the raster will be aligned. Value is in the raster's world coordinates. |
| 3315 | |
| 3316 | scalex: the scale/pixel size in the X axis of the resampled raster. This is also the scale of the grid to which the raster is being "snapped". If provided, scaley must be provided. If scalex and scaley are zero, the input raster's scale will be used. |
| 3317 | |
| 3318 | scaley: the scale/pixel size in the Y axis of the resampled raster. This is also the scale of the grid to which the raster is being "snapped" If provided, scalex must be provided. If scalex and scaley are zero, the input raster's scale will be used. |
| 3319 | |
| 3320 | 2. ST_SnapToGrid( |
| 3321 | rast raster, |
| 3322 | gridx double precision, gridy double precision, |
| 3323 | scalex double precision, scaley double precision, |
| 3324 | algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125 |
| 3325 | ) -> raster |
| 3326 | |
| 3327 | 3. ST_SnapToGrid( |
| 3328 | rast raster, |
| 3329 | gridx double precision, gridy double precision, |
| 3330 | scalexy double precision, |
| 3331 | algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125 |
| 3332 | ) -> raster |
| 3333 | |
| 3334 | scalexy: the scale/pixel size in the X and Y axes of the resampled raster. |
| 3335 | |
| 3336 | ~~ * Implemented as a wrapper around GDAL like done for ST_DumpAsPolygons()~~ |
| 3337 | ~~ * Resampling methods are the same as the one priovided by GDAL~~ |
| 3338 | |
| 3339 | ~~ '''Variants'''~~ |
| 3340 | |
| 3341 | ~~ * The '''first series of variants''' only change the pixelsize of the raster.~~ |
| 3342 | |
| 3343 | ~~ 1) ST_Resample(raster, pixelsize) - modify pixelsize only and resample using the default method~~ |
| 3344 | |
| 3345 | ~~ 2) ST_Resample(raster, method, pixelsize) - modify pixelsize and resample using the specified method~~ |
| 3346 | |
| 3347 | ~~ 3) ST_Resample(raster, pixelsizex, pixelsizey) - modify pixelsize with different values for x and y using the default method~~ |
| 3348 | |
| 3349 | ~~ 4) ST_Resample(raster, method, pixelsizex, pixelsizey) - modify pixelsize with different values for x and y using the specified method~~ |
| 3350 | |
| 3351 | ~~ * The '''second series of variants''' realign the raster and change the pixelsize~~ |
| 3352 | |
| 3353 | ~~ 5) ST_Resample(raster, x, y, pixelsize) - realign and modify pixelsize using the default method~~ |
| 3354 | |
| 3355 | ~~ 6) ST_Resample(raster, method, x, y, pixelsize) - realign and modify pixelsize using the specified method~~ |
| 3356 | |
| 3357 | ~~ 7) ST_Resample(raster, x, y, pixelsizex, pixelsizey) - realign and modify pixelsize with different values for x and y using the default method~~ |
| 3358 | |
| 3359 | ~~ 8) ST_Resample(raster, method, x, y, pixelsizex, pixelsizey) - realign and modify pixelsize with different values for x and y using the specified method~~ |
| 3360 | |
| 3361 | ~~ 9) ST_Resample(raster, x, y, pixelsizex, pixelsizey, skewx, skewy) - realign and modify pixelsize and skew with different values for x and y using the default method~~ |
| 3362 | |
| 3363 | ~~ 10) ST_Resample(raster, method, x, y, pixelsizex, pixelsizey, skewx, skewy) - realign and modify pixelsize and skew with different values for x and y using the specified method~~ |
| 3364 | |
| 3365 | ~~ * The '''third series of variants''' align and resample the raster to match the alignment, pixelsize and skew of an existing raster.~~ |
| 3366 | |
| 3367 | ~~ 11) ST_Resample(destraster, sourceraster)~~ |
| 3368 | |
| 3369 | ~~ '''Questions'''~~ |
| 3370 | |
| 3371 | ~~ * Should there be a band parameter?~~ |
| 3372 | |
| 3373 | ~~ * How does GDAL allow resampling?~~ |
| 3374 | |
| 3375 | ~~ * Which methods GDAL supports? ArcGIS supports NEAREST | BILINEAR | CUBIC | MAJORITY~~ |
| 3376 | |
| 3377 | ~~ * Does GDAL support change in skew?~~ |
| 3378 | |