I have a MODIS land cover image that contains NULL values according to r.univar:
-----
r.univar map=modis_land_cover_type1_2001_primary@PERMANENT
total null and non-null cells: 41884
total null cells: 17145
-----
So, I tried to fill it with r.fillnulls and I get the following:
-----
r.fillnulls input=MCD12Q1.A2001001.005_land_cover_type1@PERMANENT
output=MCD12Q1.A2001001.005_land_cover_type1_filled
Locating and isolating NULL areas...
Reading input raster map <r_fillnulls_1911@PERMANENT>...
Writing output raster map <r_fillnulls_1911.buf>...
Creating interpolation points...
Extracting points...
Building topology for vector map <vecttmp_fillnulls_1911>...
Registering primitives...
0 primitives registered
0 vertices registered
Building areas...
0 areas built
0 isles built
Attaching islands...
Attaching centroids...
Number of nodes: 0
Number of primitives: 0
Number of points: 0
Number of lines: 0
Number of boundaries: 0
Number of centroids: 0
Number of areas: 0
Number of isles: 0
r.to.vect complete.
Interpolating 0 points
Not sufficient points to interpolate. Maybe no hole(s) to fill in the
current map region?
Removing raster <MASK>
Removing raster <r_fillnulls_1911>
Removing raster <r_fillnulls_1911.buf>
Removing raster <r_fillnulls_1911_filled>
Raster map <r_fillnulls_1911_filled> not found
<r_fillnulls_1911_filled> nothing removed
Removing vector <vecttmp_fillnulls_1911>
(Wed Aug 4 10:18:22 2010) Command finished (0 sec)
-----
I have a MODIS land cover image that contains NULL values according to r.univar:
-----
r.univar map=modis_land_cover_type1_2001_primary@PERMANENT
total null and non-null cells: 41884
total null cells: 17145
-----
So, I tried to fill it with r.fillnulls
-----
...
Output of g.region -p:
-----
nsres: 0:00:15.210751
ewres: 0:00:15.269511
-----
Output of r.info:
-----
r.info map=modis_land_cover_type1_2001_primary@PERMANENT
Res: 0:00:00.36001
Res: 0:00:00.36002
Adjust the resolution of the current region to the MODIS image, either
g.region rast=modis_land_cover_type1_2001_primary@PERMANENT
or
g.region align=modis_land_cover_type1_2001_primary@PERMANENT
if you want to work with custom bounds.
Apart from the region resolution, it's land cover classes, r.fillnulls
will produce nonsense data: floating point. Rather use r.neighbors
with a modal filter, patch the original with the filtered map, that
would replace NULLs with the most common surrounding land cover type.
Markus M
Hanlie Pretorius wrote:
Hi,
I have a MODIS land cover image that contains NULL values according to r.univar:
-----
r.univar map=modis_land_cover_type1_2001_primary@PERMANENT
total null and non-null cells: 41884
total null cells: 17145
-----
So, I tried to fill it with r.fillnulls and I get the following:
-----
r.fillnulls input=MCD12Q1.A2001001.005_land_cover_type1@PERMANENT
output=MCD12Q1.A2001001.005_land_cover_type1_filled
Locating and isolating NULL areas...
Reading input raster map <r_fillnulls_1911@PERMANENT>...
Writing output raster map <r_fillnulls_1911.buf>...
Creating interpolation points...
Extracting points...
Building topology for vector map <vecttmp_fillnulls_1911>...
Registering primitives...
0 primitives registered
0 vertices registered
Building areas...
0 areas built
0 isles built
Attaching islands...
Attaching centroids...
Number of nodes: 0
Number of primitives: 0
Number of points: 0
Number of lines: 0
Number of boundaries: 0
Number of centroids: 0
Number of areas: 0
Number of isles: 0
r.to.vect complete.
Interpolating 0 points
Not sufficient points to interpolate. Maybe no hole(s) to fill in the
current map region?
Removing raster <MASK>
Removing raster <r_fillnulls_1911>
Removing raster <r_fillnulls_1911.buf>
Removing raster <r_fillnulls_1911_filled>
Raster map <r_fillnulls_1911_filled> not found
<r_fillnulls_1911_filled> nothing removed
Removing vector <vecttmp_fillnulls_1911>
(Wed Aug 4 10:18:22 2010) Command finished (0 sec)
-----
I have a MODIS land cover image that contains NULL values
according to r.univar:
-----
r.univar map=modis_land_cover_type1_2001_primary@PERMANENT
total null and non-null cells: 41884
total null cells: 17145
-----
So, I tried to fill it with r.fillnulls and I get the
following:
I have tried to see the NULLS by displaying everything in
white, except for NULLS displayed in red, but I didn't see
anything.
Does anyone know how I can find out if there are actually
NULL value and where they are?
try zooming in. Unless you have a 12000x7000 monitor, some cells will be
hidden.
extract with r.mapcalc and buffer with r.buffer if they are still hard to
find.
Thanks for all the replies. I first tried finding the NULLS using
r.mapcalc, and it turns out that the NULLS are the cells in the GRASS
region (rectangular), but outside my study region (irregular
geographical border). I was under the misconception that g.region set
to a raster file functions like a mask.
About the r.neighbors procedure, why is it necessary to follow with
r.patch? Surely the result of r.neighbors will be without NULLS? I did
find, though, that r.neighbours resulted in raster with extended
borders compared to the original, which makes sense. One would then
have to clip it again to the study area. Or use a mask of the original
area before running r.patch?
Thanks for all the replies. I first tried finding the NULLS using
r.mapcalc, and it turns out that the NULLS are the cells in the GRASS
region (rectangular), but outside my study region (irregular
geographical border). I was under the misconception that g.region set
to a raster file functions like a mask.
Only the N S E W bounds, no irregular border, a MASK would be required here.
About the r.neighbors procedure, why is it necessary to follow with
r.patch? Surely the result of r.neighbors will be without NULLS?
That depends on the moving window size and the size of NULL areas. If
all cells in a moving window are NULL, the result should also be NULL.
Patching makes sense only for time series of data like temperature or
vegetation indices. For land cover type, patching with different years
might not be desired.
I did
find, though, that r.neighbours resulted in raster with extended
borders compared to the original, which makes sense. One would then
have to clip it again to the study area. Or use a mask of the original
area before running r.patch?
Before doing any analysis or processing, I would set the region to the
raster including its resolution, create a MASK for the study area
maybe with a buffer around, zoom to the MASK with g.region zoom=MASK,
just to be sure align again the region to the raster resolution with
g.region align=modis_land_cover_type1_2001_primary, only now start
processing.
In this particular case, the most conservative solution would probably
be to reclassify all NULL cells as unclassified (there should be a
category value for unclassified).