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 it possible to create buffers for pixels of raster files? Actually I need to expand the pixels classified as 1 (in white in the figure) with a spatial range of 1 or 2 pixels, in order to perform some generalization. I'm using QGIS, is this possible with gdal or something?

enter image description here

share|improve this question
add comment

2 Answers

up vote 8 down vote accepted

QGIS provides an interface to GRASS GIS, which started life as a raster GIS and therefore should provide some efficient tools to tackle this problem. Referring to its manual pages of raster commands we can find the following solutions:

r.buffer -- direct buffering of white cells.

r.cost -- can compute distances to white cells. Follow this with a comparison to select short-distance cells.

r.grow -- a local morphological operation designed specifically to expand white cells into their immediate neighbors.

r.mfilter -- a general focal filter. Various focal statistics, such as max, mean, sum, median, and standard deviation can detect the presence of white cells within local neighborhoods. Follow this with a comparison to select such cells.

r.neighbors -- an even more general focal filter, which can be used similarly to r.mfilter.

r.resample -- resampling onto a coarser grid is one way to expand the white cells. The result will be somewhat "blocky".

r.spread -- letting white cells "spread" into their neighborhoods will achieve the desired buffering.

We should expect r.buffer, r.grow, and perhaps r.mfilter to use the most efficient code. (I haven't tested these to find out.)

share|improve this answer
add comment

I would argue it is possible. I'm just not sure if you can do it with QGIS, since I don't know it well enough. Can QGIS do neigborhood statistics? Assuming the black pixels are zero and the white pixels are 1, then a 3x3 neighborhood statistical function calculating the maximum of the cells will result in '1' for the adjacent pixels of the white border. You can then isolate those pixels in a second procedure (or run neighborhood stats a second time for a second row of pixels).

share|improve this answer
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.