Le jeudi 13 décembre 2012 19:58:50, Jorge Arevalo a écrit : > Hello, > > I want to modify every single pixel of a 1 band GeoTiff file, > following a formula (multiply each pixel for a value and then add > another value). > > output_pixel[i][j] = input_pixel[i][j] * K[i][j] + C[i][j] > > I can't apply a linear scale (it would be as easier as -scale option > in gdal_translate). Sounds more like applying a mask to the band's > data. > > My first approach is to get every data block of the raster (IReadBlock > call), apply the transformation to every single pixel ( = apply a mask > to the data block), and put the block in the output raster. > > Is there any other faster/smarter approach?
I would follow exactly the same approach. If you don't do in-place update, be carefull that the source and target rasters have exactly the same block size and data type if you want to use directly ReadBlock() / WriteBlock(). If not, you must use ReadBlock() / RasterIO(GF_Write, ....) _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
