[GRASS-user] Re: r.fillnulls for large area

pkscwc pkscwc at gmail.com
Sat Dec 3 02:39:51 EST 2011

Dear Nick,

I am working on SRTM rasters of resolution 1km, 500m, 250m and recently 90m
using GRASS for long and had countered the problem being faced by you.

My workaround is given below and as a by-product you may get a very nice
coastline vector/raster also.

1. I have converted  all the nulls with r.mapcalc to -160 using the formula
C=if(A, if(isnull(B),-160,B))
A: region of interest
B: original srtm raster with nulls for sea and holes
C: Output map in which nulls have been converted to -160. 

(Why -160, because in my map, as from my human memory, the lowest value was
-70. I just chose a value lower than this value. We will need it later on to
convert back them as holes for r.fillnulls to work upon.)

A sample from the history file of the raster is produced below:

Sun Aug  1 17:49:10 2010

generated by r.mapcalc
if(test_nL_region at PERMANENT, if(isnull(ib2 at PERMANENT), -160, ib2 at PERMANENT))

A: test_nL_region

This raster map is a region of my interest out the big srtm raster converted
from a vector. Grass has a command , which converts the current region to a
vector file.
Again, the sample from the history file of the raster is produced below:

ed Jul 28 10:09:42 2010
Vector Map: nL_region at PERMANENT in mapset PERMANENT
Original scale from vector map: 1:1
generated by v.to.rast
v.to.rast input="nL_region at PERMANENT" output="test_nL_region" use="c\
at" type="point,line,area" layer=1 value=1 rows=4096

Again, the sample from the history file of the vector is produced below:
COMMAND: v.in.region output="nL_region" type="area" cat=1
GISDBASE: /home/pks/renamed_grassdata
LOCATION: newLocation MAPSET: PERMANENT USER: pks DATE: Wed Jul 28 09:53:43

So, now we have -160s all around , i.e. the sea and holes on land.

Now use the r.reclass.area feature to differentiate sea from  holes on land.
A sample from my recent work is given below:

Tue Nov  8 13:55:47 2011
Reclassified map based on:
  Map [bi_reclassed3.clump.bi_reclassed3_area] in mapset [work2]
generated by r.reclass

I am using GRASS7 and in the history given above , all the parameters are
not available.
In my case , I used 1 billion hectare as "greater than area" parameter to
bring out the sea , land , and holes in land in different categories.

Thereafter, use mask and pick up the landmass with holes in land , which you
want to fill. 
Just remember to convert back the -160 to null again.

I felt that r.fillnulls works best when the nulls have values around them.

By the way, CGIAR provides holes-filled-SRTM-raster.You may like to read
their literature for understanding the algorithms used to fill the nulls.
It's good and useful.

Try this link for downloading clean rasters of your area of interest:


Hope, it helps.

Some of my observations are listed below:
1. If the system lacks RAM, then  increase patience.
2. If the system lacks hard-disk space, don't go for GIS.
3. Learn python.

View this message in context: http://osgeo-org.1803224.n2.nabble.com/r-fillnulls-for-large-area-tp7047337p7057352.html
Sent from the Grass - Users mailing list archive at Nabble.com.

More information about the grass-user mailing list