[postgis-devel] WKTRaster ST_MapAlgebra

David Zwarg dzwarg at avencia.com
Wed Feb 17 10:36:58 PST 2010


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.

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.

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.

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.

Finally, a question: how about I start fleshing out ST_MapAlgebra (spec)
with the following rules?

   - Rasters with different projections cannot be combined.
   - Rasters with different cell sizes will produce an output raster with
   the largest of the input raster cell sizes.
   - Rasters with different extents produce an output raster with the extent
   of the intersection of the input rasters.

Thanks,
Zwarg


On Tue, Feb 9, 2010 at 5:06 PM, George Silva <georger.silva at gmail.com>wrote:

> ArcGIS if I'm not mistaken projects rasters on the fly to do the
> operations.
>
> George
>
> On Tue, Feb 9, 2010 at 7:29 PM, Pierre Racine <Pierre.Racine at sbf.ulaval.ca
> > wrote:
>
>>  This is a good question…
>>
>>
>>
>> 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.
>>
>>
>>
>> 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.
>>
>>
>>
>> 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).
>>
>>
>>
>> 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.
>>
>>
>>
>> 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.
>>
>>
>>
>> Pierre
>>
>>
>>
>> *From:* postgis-devel-bounces at postgis.refractions.net [mailto:
>> postgis-devel-bounces at postgis.refractions.net] *On Behalf Of *David Zwarg
>> *Sent:* 9 février 2010 15:54
>> *To:* PostGIS Development Discussion
>> *Subject:* [postgis-devel] WKTRaster ST_MapAlgebra
>>
>>
>>
>> Greetings,
>>
>> I was reviewing the working spec (
>> http://trac.osgeo.org/postgis/wiki/WKTRaster/SpecificationWorking03), and
>> thinking about ST_MapAlgebra:
>>
>> *ST_MapAlgebra(raster|geometry, [raster|geometry,…], ‘mathematical
>> expression’, ‘raster’ |’geometry’) -> raster/geometry*
>>
>> 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?
>>
>> Thanks,
>> Zwarg
>>
>> _______________________________________________
>> postgis-devel mailing list
>> postgis-devel at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-devel
>>
>>
>
>
> --
> George R. C. Silva
>
> Desenvolvimento em GIS
> http://blog.geoprocessamento.net
>
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20100217/7d1213bf/attachment.html>


More information about the postgis-devel mailing list