I have investigated these operations in ArcGIS and GRASS (to the best of my ability, I still can't figure out reprojecting). I did not look into R.<br><br>In both applications, the map algebra operations are performed on cells that exist in both rasters. If the rasters have different extents, then the resulting raster has data only in the region where they intersect.  This is also true when rasters have the same extent and contain NODATA values.<br>
<br>In both applications, the cell size of the resulting raster is the same as the largest input cell size.  So if two rasters are provided as input, one with a cell size of 5, and another with a cell size of 9, the resulting raster has a cell size of 9.  In ArcGIS, I was able to confirm that even when the grid orientation is different (when comparing 2 different projections, for example), the cells are interpolated to the larger cell size.<br>
<br>In ArcGIS, when map algebra is performed on two rasters with different projections/coordinate systems, the first raster wins.  The second raster is reprojected on the fly to the first coordinate system, and the resulting raster has the same coordinate system as the first input raster.  I was not able to figure out how to perform map algebra in GRASS with rasters in two different projected coordinate systems.<br>
<br>Finally, a question: how about I start fleshing out ST_MapAlgebra (spec) with the following rules?<br><ul><li>Rasters with different projections cannot be combined.</li><li>Rasters with different cell sizes will produce an output raster with the largest of the input raster cell sizes.</li>
<li>Rasters with different extents produce an output raster with the extent of the intersection of the input rasters.<br></li></ul>Thanks,<br>Zwarg<br><br><br><div class="gmail_quote">On Tue, Feb 9, 2010 at 5:06 PM, George Silva <span dir="ltr"><<a href="mailto:georger.silva@gmail.com">georger.silva@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">ArcGIS if I'm not mistaken projects rasters on the fly to do the operations.<br><font color="#888888"><br>
George<br><br></font><div class="gmail_quote"><div class="im">On Tue, Feb 9, 2010 at 7:29 PM, Pierre Racine <span dir="ltr"><<a href="mailto:Pierre.Racine@sbf.ulaval.ca" target="_blank">Pierre.Racine@sbf.ulaval.ca</a>></span> wrote:<br>


</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">








<div link="blue" vlink="purple" lang="EN-US">

<div>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">This is a good question…</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">I guess users would expect the same kind of result as in any GIS
package: The pixel values used to compute the mathematical expression SHOULD spatially
overlap.</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">For operations like this in general, PostGIS assume that
involved layers are in the same coordinate system. There is no such things as
automatic on the fly layer reprojection. I don’t remember if it warn you
if it you attempt an operation on two layers projected in two different CS. </span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Now what to do when the rasters ovelaps but the pixel sizes are
different? Or when they have different rotations? What does GRASS does? What
does ArcGIS does? Whar R does? I would definitely play with those before designing
anything. We should design the rules involved in this kind of function so we
can reuse them when we are confronted to similar alignment problem in other functions
(Intersection(raster, raster)->raster, ST_Difference(raster A, raster B)->raster,
i.e. most functions taking two or more overlapping rasters and returning one
raster). </span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">You also always have to decide what will be the CS, alignment and
pixel size of the resulting raster. You can impose the ones of one of the
raster involved (the “master raster”) with an integer parameter
specifying the index of the “master raster”. You could also supply
variant of the function allowing to specify these params. Do we want to
realign/resample slave rasters before doing te operation. This does not seems
very efficient but maybe there is no other real avenue.</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">For sure the challenge is huge. I would maybe start by
implementing supports for operations on a single raster, delaying problems of
alignment for later.</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Pierre</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>

<div style="border-style: none none none solid; border-color: -moz-use-text-color -moz-use-text-color -moz-use-text-color blue; border-width: medium medium medium 1.5pt; padding: 0cm 0cm 0cm 4pt;">

<div>

<div style="border-style: solid none none; border-color: rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color; border-width: 1pt medium medium; padding: 3pt 0cm 0cm;">

<p class="MsoNormal"><b><span style="font-size: 10pt;">From:</span></b><span style="font-size: 10pt;">
<a href="mailto:postgis-devel-bounces@postgis.refractions.net" target="_blank">postgis-devel-bounces@postgis.refractions.net</a>
[mailto:<a href="mailto:postgis-devel-bounces@postgis.refractions.net" target="_blank">postgis-devel-bounces@postgis.refractions.net</a>] <b>On Behalf Of </b>David
Zwarg<br>
<b>Sent:</b> 9 février 2010 15:54<br>
<b>To:</b> PostGIS Development Discussion<br>
<b>Subject:</b> [postgis-devel] WKTRaster ST_MapAlgebra</span></p>

</div>

</div><div><div></div><div>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Greetings,<br>
<br>
I was reviewing the working spec (<a href="http://trac.osgeo.org/postgis/wiki/WKTRaster/SpecificationWorking03" target="_blank">http://trac.osgeo.org/postgis/wiki/WKTRaster/SpecificationWorking03</a>),
and thinking about ST_MapAlgebra:<br>
<br>
<b>ST_MapAlgebra(raster|geometry, [raster|geometry,…],
‘mathematical expression’, ‘raster’
|’geometry’) -> raster/geometry</b><br>
<br>
I am considering the following question in the context of using ST_MapAlgebra
with rasters, and returning a raster. Should this function only perform
operations on similar rasters?  Meaning: do the georeferencing, spatial
reference, and pixel size have to be the same in all input rasters?<br>
<br>
Thanks,<br>
Zwarg</p>

</div></div></div>

</div>

</div>


<br></div></div><div class="im">_______________________________________________<br>
postgis-devel mailing list<br>
<a href="mailto:postgis-devel@postgis.refractions.net" target="_blank">postgis-devel@postgis.refractions.net</a><br>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-devel" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-devel</a><br>
<br></div></blockquote></div><br><br clear="all"><div><div></div><div class="h5"><br>-- <br>George R. C. Silva<br><br>Desenvolvimento em GIS<br><a href="http://blog.geoprocessamento.net" target="_blank">http://blog.geoprocessamento.net</a><br>

</div></div><br>_______________________________________________<br>
postgis-devel mailing list<br>
<a href="mailto:postgis-devel@postgis.refractions.net">postgis-devel@postgis.refractions.net</a><br>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-devel" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-devel</a><br>
<br></blockquote></div><br>