Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to calculate the difference of two bands. I have the individual bands stored somewhere, but I was thinking that maybe there's a way of producing a VRT file that is the result of this difference. I know that you can use pixel functions in GDAL, but this limits the use (C++, and only available when the function is linked in...).

It would be nice if simple "virtual" operations were available!

share|improve this question
up vote 1 down vote accepted

Not easily, yet...

There are a couple of ways around though. In C++ you can compile the pixel function then dynamically register it by using the GDAL plugin mechanism (there are some examples here). Or even more interesting to Python scribblers like myself, you can write pixel functions in Python!

share|improve this answer
OK, I wasn't aware that you could write python pixel functions. I guess that's as good as it gets :) – Jose Dec 7 '11 at 14:48
While theoretically you can write VRT pixel functions in Python, I imagine that would be rather inefficient. I'd think you'd be better served letting more optimized code do the heavy lifting, i.e. use a GIS (qgis, ESRI, etc.) or numpy if you're writing scripts. – Luke Dec 8 '11 at 0:30

Your Answer


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.