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.

Is there any code to add a float or integer value with a raster layer? I can easily do mathematical operations between two raster data. But I am unable to do the same between float or integer number and raster layer. For example if want to execute (256-band3), how can I execute?

share|improve this question
1  
What software are you using? –  whuber Feb 12 '12 at 7:13
add comment

3 Answers

If you have a copy of FME then you can use the RasterExpressionEvaluator transformer.

In this case (256-band3) the expression would be simply:

256-A[2]

(FME labels bands as 0,1,2 rather than 1,2,3).

The nice thing is that it also allows IF statements, so you can work up to complex statements like:

if ((A[0]+A[1]+A[2])==0, 255, A[0])

This page on FMEpedia has a bunch of examples.

share|improve this answer
add comment

Try the raster package in R. Something like:

r = raster("foo.tif") + 255
writeRaster(r,"foo.tif",overwrite=TRUE)
share|improve this answer
    
it is not so much difficult. use the following expressionIMapAlgebraOp mapAlgebraOp; –  mintu medhi Feb 17 '12 at 14:41
add comment

Try RasterCalc plugin for QGis.

share|improve this answer
add comment

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

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.