Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I've looked through the PostGIS raster documentation, but can't find an indication of how to apply a convolution filter to raster data. Does this capability even exist (yet?) There only appears to be preset operators such as min, max and std deviation.

share|improve this question
    
What about postgis.org/documentation/manual-svn/…? This is more general than a convolution (with both good and bad implications: the good is that you can in principle do lots of neighborhood analyses; the bad is that (a) the convolution kernel apparently needs to be hard-coded and (b) actual convolutions can be extremely slow because they won't exploit FFT methods). –  whuber Mar 26 '12 at 18:49
1  
heh. And it has great parameter names! "onerastngbuserfunc" makes my eyes roll backwards. @whuber Feel free to make this an answer and I'll add to your heap; ST_MapAlgebraFctNgb isn't entirely what I was expecting but you're right it is a very flexible method. –  WolfOdrade Mar 26 '12 at 20:09

1 Answer 1

up vote 1 down vote accepted

A discussion carried out in comments to the question has established that indeed PostGIS can perform convolutions by means of the ST_MapAlgebraFctNgb procedure. This provides a way to apply a user-supplied function systematically to all neighborhoods within a raster. Any function that is a weighted linear combination of the inputs (with constant weights across the raster) is a convolution, by definition.

This approach is remarkably flexible: it should be able to accommodate any kind of neighborhood statistic (mean, median, range, variance, variety, etc.) in addition to actual convolutions. The flip side is that it can be slow: there will be one neighborhood for each grid cell, so the processing time will usually be proportional to the grid size times the neighborhood size. For medium to large neighborhoods that can be onerous. Methods based on the Fast Fourier Transform can compute any convolution you want and take effort proportional to the grid size times its logarithm. For medium to large neighborhoods (typically the crossover is around 5 by 5 to 10 by 10 in size), that can be a big difference. In such cases one would seek alternative software solutions.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.