[postgis-devel] WKTRaster ST_MapAlgebra

Pierre Racine Pierre.Racine at sbf.ulaval.ca
Fri Feb 19 08:43:07 PST 2010


>Ok, I've come to the conclusion that rasters in the same coordinate system have the same rotation (in
>ArcGIS), since I can't seem to rotate a raster without processing it into a set of new cells on the
>same grid.

False. Two rasters in the same coordinate system may have different rotations (in their georeference). You can rotate a raster in ArcMap in the Georeferencing tool bar using the rotate tool. You can then export the georeference as a World file (in ArcToolBox). The rotation parameters are the D and B parameters in a World File (http://en.wikipedia.org/wiki/World_file). This has nothing to do with the coordinate system.

It is hard to play with geotiff because the georeference in the geotiff always has precedence on the world file (please confirm). One way to test is to rotate a geotiff in ArcMap using the Georeferencing toolbar, export the World file, convert the tif to jpeg, change the name of the world file to match the one of the jpeg and then open the jpeg. You can then play with the rotation directly in the world file. Adding to the confusion is the fact that some softwares do not support display or conversion of rotated raster file.

>As for alignment: the alignment of the grid starts at the intersecting boundary.  This is true for the
>left and bottom coordinates -- the right and top coordinates are constrained by the new cell size *
>intersection width/height.  It's possible that the grid in the intersection does not cover the entire
>intersecting area if there is an odd remainder.
>
>Example:
>* raster A : cell size: 4, width: 8 cells (32 units), height: 8 cells (32 units)
>* raster B : cell size: 9, width: 10 cells, height: 10 cells
>* raster A's envelope is completely inside of raster B
>I would assume that under those conditions, the output raster would have the same envelope as A.  What
>actually happens is that the output cell size is set to 9, and the closet dimension that fits inside
>of A's envelope is 9 units X 3 cells = 27. There is a difference of 5 units between the envelope of
>the output raster and raster A.  The grid starts at raster A's bottom left coordinate, so the 5 units
>of data lost are the topmost and rightmost cells in raster A.

Having this result I would feel that I loose information in the process. I would probably have prefered that the resulting raster cell size matches the A raster cell size. I would then like to be able to specify the input raster that give its cell size to the output raster. This is what I would call the "master raster". It could simply be the first raster passed to the function. I would probably also like to set my own cell size as well.

>So it would appear that the resample operation does imply a realignment (I can confirm translation
>only, not rotation), and that it is not possible to resample without realignment.

PostGIS has a function which snap geometries to a grid (http://postgis.refractions.net/documentation/manual-1.5/ST_SnapToGrid.html) I would probably want to be able to similarly snap my raster to a grid like this when resampling. These parameter should be passsable to both ST_MapAlgebra() and ST_Resample(). We could also create a RasterGrid kind of object carrying those four parameters. Then we would have full control over the alignment/cell size of resulting rasters in many operations. A feature that lack in many package (maybe I'm too adventurous here).

Pierre

PS. Please write your mails in ASCII mode. It's easier to reply.



More information about the postgis-devel mailing list