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 am attempting to set the value of a pixel based on its current value. I am using the Raster Calculator in Quantum GIS dev 1.7 trunk.

For example, if the value is 0, I want to set it to 255.

Based on an example that I found, something like this should work, but it doesn't.

myRaster@1=0 255 

The RasterCalc plugin appears to use a function syntax, but that doesn't appear to be valid either

eq( myRaster@1, 0, 255)

Any suggestions? Thanks.

share|improve this question
add comment

2 Answers 2

Technically I think you can do it. Say you wanted to assign 0 the value 255, 1 the value 142, 2 the value 719, and all other values to 0. I believe this would work:

((myRaster@1=0)*255 + (myRaster@1=1)*142 + (myRaster@1=2)*719)*(myRaster@1<3)

I used a similar approach to pull two values out of one raster, assign the composite raster 0 for both of those values, then do a specific calculation using two rasters for all other values in the first raster. I'm using QGIS 1.8.0.

share|improve this answer
    
+1 Welcome to our site! –  whuber Oct 15 '12 at 13:50
add comment

As far as I know, this kind of query is not possible with the built-in raster calculator but only with "RasterCalc" plugin by gis-lab.

RasterCalc syntax is:

eq( [relief]@1, 50, 200 )

Compare: http://gis-lab.info/qa/rastercalc-eng.html

share|improve this answer
    
That syntax doesn't work with the built-in Raster Calculator in v1.7. –  DavidF Mar 4 '11 at 5:01
    
No, only with RasterCalc plugin. Two different things. Quite confusing, I think. –  underdark Mar 4 '11 at 7:11
add comment

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.