[GRASSLIST:6310] filling nulls in integer raster

Greetings,

i have a raster image that i am hoping to vectorize after a bit of
generalization with r.reclass.area... however, r.reclass.area leaves nulls in
the middle of larger areas of equal value:

http://169.237.35.250/~dylan/temp/holes.png

i have tried to fill these holes, with r.fillnulls (via RST interpolation)
with:
r.fillnulls in=asp.large out=asp.final smooth=.01 tension=100

and the result looks something like this:

http://169.237.35.250/~dylan/temp/fewer_holes.png

...however, is there anyway to get rid of all the nulls, replacing them with
the value that is surrounding them?

thanks in advance

--
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341

what do you think of the neighborhood modifier:

1 change the null value to eg. 0

2 r.mapcalc 'map_filled=if(map==0,mode(map[-1,-1],map[-1,0],map[-1,1],map[0,1],map[1,1],map[1,0],map[1,-1],map[0,-1]),map)'

3 repeat until no zeros (may be recognized with "r.info -r map_filled") if needed

or maybe mask the non-null areas, r.grow the mask a few pixels, r.neighbors, g.remove MASK, r.patch?

Maciek

----- Original Message ----- From: "Dylan Beaudette" <dylan@iici.no-ip.org>
To: <GRASSLIST@baylor.edu>
Sent: Friday, April 01, 2005 9:55 PM
Subject: [GRASSLIST:6310] filling nulls in integer raster

Greetings,

i have a raster image that i am hoping to vectorize after a bit of
generalization with r.reclass.area... however, r.reclass.area leaves nulls
in
the middle of larger areas of equal value:

http://169.237.35.250/~dylan/temp/holes.png

i have tried to fill these holes, with r.fillnulls (via RST interpolation)
with:
r.fillnulls in=asp.large out=asp.final smooth=.01 tension=100

and the result looks something like this:

http://169.237.35.250/~dylan/temp/fewer_holes.png

...however, is there anyway to get rid of all the nulls, replacing them
with
the value that is surrounding them?

thanks in advance

--
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341

i have a raster image that i am hoping to vectorize after a bit of
generalization with r.reclass.area... however, r.reclass.area leaves
nulls in the middle of larger areas of equal value:

http://169.237.35.250/~dylan/temp/holes.png

i have tried to fill these holes, with r.fillnulls (via RST
interpolation) with:
r.fillnulls in=asp.large out=asp.final smooth=.01 tension=100

and the result looks something like this:

http://169.237.35.250/~dylan/temp/fewer_holes.png

...however, is there anyway to get rid of all the nulls, replacing
them with the value that is surrounding them?

sneaking suspicion: there are no NULLs.

try running r.univar on the map to count number of NULLs.

It may be that the color map does not cover the whole range of data, and
the out of bounds areas are left looking blank. Try running r.colors on
the new map. If the map should be categorical, and as r.fillnulls
returns a floating point map, you might also try feeding through
r.mapcalc:

r.mapcalc 'new_map=int(old_map)'

maybe with int(old_map+0.5) if you want rounding. (int() just chops off
everything to the right of the decimal place)

?
Hamish

Maciek,

interesting idea,

I tried using r.neighborhood as well, and it seemed to work ok.

however, i have since discovered that for this particular raster (as classified slope map of very complex terrain) it was simpler to generalize the slope map via r.param.scale. since we are mapping at a rather coarse scale, this method actually captures the larger terrain features, while masking out the smaller ones..!

i was able to vectorize, and then clean with tool=rmarea to get rid of any remaining small areas

thanks!

--
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341

On Apr 1, 2005, at 1:07 PM, Maciek Sieczka wrote:

what do you think of the neighborhood modifier:

1 change the null value to eg. 0

2 r.mapcalc 'map_filled=if(map==0,mode(map[-1,-1],map[-1,0],map[-1,1],map[0,1],map[1,1],map[1,0],map[1,-1],map[0,-1]),map)'

3 repeat until no zeros (may be recognized with "r.info -r map_filled") if needed

or maybe mask the non-null areas, r.grow the mask a few pixels, r.neighbors, g.remove MASK, r.patch?

Maciek

----- Original Message ----- From: "Dylan Beaudette" <dylan@iici.no-ip.org>
To: <GRASSLIST@baylor.edu>
Sent: Friday, April 01, 2005 9:55 PM
Subject: [GRASSLIST:6310] filling nulls in integer raster

Greetings,

i have a raster image that i am hoping to vectorize after a bit of
generalization with r.reclass.area... however, r.reclass.area leaves nulls
in
the middle of larger areas of equal value:

http://169.237.35.250/~dylan/temp/holes.png

i have tried to fill these holes, with r.fillnulls (via RST interpolation)
with:
r.fillnulls in=asp.large out=asp.final smooth=.01 tension=100

and the result looks something like this:

http://169.237.35.250/~dylan/temp/fewer_holes.png

...however, is there anyway to get rid of all the nulls, replacing them
with
the value that is surrounding them?

thanks in advance

--
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341