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 have a raster map in GRASS that looks like this:

Raster map with binary values

The red cells have a value of 1, the yellow cells have a value of 0.

I am trying to use the r.grow command to 'fill in' the gaps in the red lines, but it seems that whatever options I give the command, the output is either exactly the same as the input, or entirely 1, or entirely 0.

The way to run the command that seems most sensible is:

r.grow input=extracted@PERMANENT output=gr8 radius=3.01

which, as far as I can tell, should grow all positive cells by 3 cells. However, it doesn't seem to do anything at all - the output map is exactly the same as the input map. Changing the old and new values doesn't seem to change it either.

Am I doing something wrong here? I have read through the manual page for the r.grow command many times, but can't see what I'm missing.

share|improve this question
1  
Do you mean that the yellow has a value of zero or that it is null? The manual page says that the non-null cells are expanded only into the null cells (which, by default, apparently are encoded with the value -1, not zero). –  whuber Nov 23 '12 at 21:19
1  
Ah yes, that seems to solve it. I didn't notice that it was talking about NULL pixels, rather than 0 pixels (or maybe I was just used to grow functions working with {0,1} rasters rather than {NULL,1} rasters. If you add this as an answer then I'll accept it. Thanks! –  robintw Nov 25 '12 at 18:12
2  
Furthermore, you can use the r.null command to set zero values to NULL: r.null <rast_map> setnull=0 –  Micha Nov 25 '12 at 19:53
    
(+1 for the question.) I have converted the comment into a formal answer. Glad it helped! –  whuber Feb 24 '13 at 20:19

1 Answer 1

up vote 2 down vote accepted

The manual page says that the non-null cells are expanded only into the null cells (which, by default, apparently are encoded with the value -1, not zero).

In a comment, @Micha states you can use r.null to convert the zero values to nulls, as in

 r.null <rast_map> setnull=0

After you make such a change, r.grow should produce the expected output.

share|improve this answer

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.