[GRASS-user] i.maxlik: strange classification output and reject map

I have three maps which are 1) shortwave infrared reflectances derived from Landsat ETM+ (Data Type: FCELL); 2) cumulative solar radiation derived using "r.sun" from GRASS (Data Type: FCELL); 3) elevation map (DEM, Data Type: CELL).
I am trying to perform a supervised maximum likelihood classification over these bands.
So, first I grouped them using "i.group".
Then I imported a shp with rock glacier areas, created a new column in its attribute table called "IDmaxlik" and assigned a value of "1" (int) to it.
Then I converted the shp to raster with this command:

     v.to.rast in=rg_visible out=rg_visible use=attr attribute_column=IDmaxlik

and I used "i.gensig" to generate the signature file.

     i.gensig trainingmap=rg_visible group=perma_max subgroup=perma_max signaturefile=rg_sig

Finally, I run "i.maxlik":

     i.maxlik group=perma_max subgroup=perma_max signaturefile=rg_sig output=classification01 reject=classification01_reject

Each pixel of the output map ("classification01") is 1, as if the everything was classified as "rock glacier". Moreover, the reject map ("classification01_reject"), has higher values (closer to 16, or 100%) over the same rock glaciers used as the region of interest than elsewhere.

Might be the problem related to the fact that "i.gensig" expected a clip of the RGB raster on the ROIs, rather than a mask?

On 20/12/15 14:43, Umberto Filippo Minora wrote:

I have three maps which are 1) shortwave infrared reflectances derived
from Landsat ETM+ (Data Type: FCELL); 2) cumulative solar radiation
derived using "r.sun" from GRASS (Data Type: FCELL); 3) elevation map
(DEM, Data Type: CELL).
I am trying to perform a supervised maximum likelihood classification
over these bands.
So, first I grouped them using "i.group".
Then I imported a shp with rock glacier areas, created a new column in
its attribute table called "IDmaxlik" and assigned a value of "1" (int)
to it.
Then I converted the shp to raster with this command:

      v.to.rast in=rg_visible out=rg_visible use=attr
attribute_column=IDmaxlik

and I used "i.gensig" to generate the signature file.

      i.gensig trainingmap=rg_visible group=perma_max subgroup=perma_max
signaturefile=rg_sig

Finally, I run "i.maxlik":

      i.maxlik group=perma_max subgroup=perma_max signaturefile=rg_sig
output=classification01 reject=classification01_reject

Each pixel of the output map ("classification01") is 1, as if the
everything was classified as "rock glacier". Moreover, the reject map
("classification01_reject"), has higher values (closer to 16, or 100%)
over the same rock glaciers used as the region of interest than elsewhere.

Might be the problem related to the fact that "i.gensig" expected a clip
of the RGB raster on the ROIs, rather than a mask?

No, I think the problem stems from the fact that you only provide one class, so each pixel is attributed to that class. If the rest of the area is quite heterogeneous you should probably even create several other classes and respective training areas.

Moritz

Hi Moritz,

Thanks for the answer.
All right, I will try that, although I thought it could work also for one class (keeping the rest unclassified).I also tried rescaling my images to range 0-255, but that didn’t solve the problem.
Still, it’s strange that the reject map gives 100% (or close to) over the ROIs, I would expect the opposite…

Will come back to say if adding more classes solves the problem when I try.
cheers,
Umberto

Il 21/12/15 14:29, Moritz Lennert mlennert@club.worldonline.be ha scritto:

On 20/12/15 14:43, Umberto Filippo Minora wrote:

I have three maps which are 1) shortwave infrared reflectances derived
from Landsat ETM+ (Data Type: FCELL); 2) cumulative solar radiation
derived using “r.sun” from GRASS (Data Type: FCELL); 3) elevation map
(DEM, Data Type: CELL).
I am trying to perform a supervised maximum likelihood classification
over these bands.
So, first I grouped them using “i.group”.
Then I imported a shp with rock glacier areas, created a new column in
its attribute table called “IDmaxlik” and assigned a value of “1” (int)
to it.
Then I converted the shp to raster with this command:

v.to.rast in=rg_visible out=rg_visible use=attr
attribute_column=IDmaxlik

and I used “i.gensig” to generate the signature file.

i.gensig trainingmap=rg_visible group=perma_max subgroup=perma_max
signaturefile=rg_sig

Finally, I run “i.maxlik”:

i.maxlik group=perma_max subgroup=perma_max signaturefile=rg_sig
output=classification01 reject=classification01_reject

Each pixel of the output map (“classification01”) is 1, as if the
everything was classified as “rock glacier”. Moreover, the reject map
(“classification01_reject”), has higher values (closer to 16, or 100%)
over the same rock glaciers used as the region of interest than elsewhere.

Might be the problem related to the fact that “i.gensig” expected a clip
of the RGB raster on the ROIs, rather than a mask?

No, I think the problem stems from the fact that you only provide one class, so each pixel is attributed to that class. If the rest of the area is quite heterogeneous you should probably even create several other classes and respective training areas.

Moritz

Also, in my specific case, I would have to avoid adding other classes.
To clarify why it should be like so: my study area is a mountainuous area in
North-West Italy. I masked features such as water bodies, snow, glaciers,
vegetation, and so on, to obtain a map of bare soil only. Now, in this
unmasked area, some rock glaciers (i.e. glaciers that are "buried" in the
ground) are present. I have their locations in form of polygons, and now I
want to use these outlines as my region of interests (ROIs) for the
Supervised Classification with i.maxlik on the RGB composed by 1) the
elvation map, 2) the band4 of Landsat ETM+, and 3) the cumulative solar
radiation map.
The aim is to classify the pixels in the unmasked area out of the rock
glacier outlines which are similar to the rock glaciers with the maximum
likelihood algorithm, according to the three mentioned RGB band values. *As
I don't know what is around the rock glaciers, I am not able to specify
other classes unfortunately.*
So, is there a way I can do a Supervised with only one class in GRASS? Would
you suggest another software (better if open source)?

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/i-maxlik-strange-classification-output-and-reject-map-tp5242179p5242335.html
Sent from the Grass - Users mailing list archive at Nabble.com.

On 21/12/15 16:42, umberto.minora wrote:

Also, in my specific case, I would have to avoid adding other classes.
To clarify why it should be like so: my study area is a mountainuous area in
North-West Italy. I masked features such as water bodies, snow, glaciers,
vegetation, and so on, to obtain a map of bare soil only. Now, in this
unmasked area, some rock glaciers (i.e. glaciers that are "buried" in the
ground) are present. I have their locations in form of polygons, and now I
want to use these outlines as my region of interests (ROIs) for the
Supervised Classification with i.maxlik on the RGB composed by 1) the
elvation map, 2) the band4 of Landsat ETM+, and 3) the cumulative solar
radiation map.
The aim is to classify the pixels in the unmasked area out of the rock
glacier outlines which are similar to the rock glaciers with the maximum
likelihood algorithm, according to the three mentioned RGB band values. *As
I don't know what is around the rock glaciers, I am not able to specify
other classes unfortunately.*
So, is there a way I can do a Supervised with only one class in GRASS? Would
you suggest another software (better if open source)?

A maximum likelihood classifier (and most classifiers actually) will classify each pixel in the class for which the likelihood that it belongs to that particular class is highest. If you only have one class, this class will always be the likeliest.

The only option would be to use the reject map, and decide on a threshold there. But apparently you've tried that without success.

Can't you visually identify areas for which you know that they are not rock glaciers ?

Moritz

Hi and thanks again.

Actually, there are no rock glaciers in the study area rather than those I
have already mapped (hopefully). The reason why I am using a superviosed is
because I am using the rock glaciers (i.e. the cumulative solar radiation,
the band 4 reflectance, and elevation) as a proxy of permafrost presence,
which is not visible. The aim is to map it using the statistics held in the
RGB over the rock glaciers.
As you said, the way is to use the rejection map, but strangely I have more
rejection on the rock glaciers themselves which were used as ROIs, than
elsewhere. This sounds quite strange to me, and this is something I would
need to fix to go on.

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/i-maxlik-strange-classification-output-and-reject-map-tp5242179p5242364.html
Sent from the Grass - Users mailing list archive at Nabble.com.

I am back to this classification issue because I could not find a way to have
it working the way I need.
Let's keep it simple: my need is to do a SML with only one class. As far as
I know, in other softwares (e.g. ENVI) it is possible to make it with only
one class, and then specify a likelihood threshold (as a precentage), to
which each pixel in the image to be classified is assigned or not to the
class. In GRASS I think it would work similarly, in the sense that I don't
specify any percentage of likelihood, but I can look at the reject map.
Still, I don't understand why over the ROIs I have more rejection than
elsewhere. Shouldn't it be the opposite? I know I already asked so, but it's
important for me to understand if something I am doing is wrong. Thanks for
any hints or help, it would be very much appreciated.

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/i-maxlik-strange-classification-output-and-reject-map-tp5242179p5245683.html
Sent from the Grass - Users mailing list archive at Nabble.com.

I performed again the supervised maximum likelihood, and I came to the
conclusion that the rejection map is to be interpreted as the opposite as it
is stated in the manual of 'i.maxlik'.
My code is attached below, so anyone can see the steps I am doing before
calling 'i.maxlik'.
Looking at the zonal statistics of the rejection map (extracted with
'v.rast.stats' and then 'db.out.ogr'), the rejection is very high all over
my training areas. Moreover, in the attached images you can see 1) the rgb
of my area, 2) the area without the masked regions, and 3) the rejection map
with the training areas (the rock glaciers, in red). This last was obtained
by running 'i.maxlik' against the unmasked image. Surprisingly, the dark
areas (which are supposed to be low rejkection areas) fit well with the
masked area. Interpreting this results, I think I can choose a high
threshold of rejection to classify the image the way I want.
I would be happy if somebody would like to share some opinions on this, I am
completely available also at re-doing the work and add more details.
Following, the lines of code I ran, the signature file, the zonal stats, and
the three images.

*CODE*
## Supervised classification using GRASS70
# import the raster maps
r.in.gdal /path/to/band4_refl.tif output=band4_refl
r.in.gdal /path/to/cumRAD_152-259.tif output=cumRAD_152-259
r.in.gdal /path/to/dem.tif output=dem

# import the training areas (vector)
v.in.ogr /path/to/rg_visible.shp output=rg_visible

# add a column with the ID of the class to be found by the maximumLikelihood
# algorithm (only one class in this case, the "rock glacier" class, code 1)
v.db.addcolumn rg_visible columns="IDmaxlik integer"
v.db.update rg_visible column=IDmaxlik value=1

# align the region of the vector RG to one of the raster maps, and convert
it to raster using
# column "IDmaxlik" as pixel value
g.region vector=rg_visible align=band4_refl -p
v.to.rast in=rg_visible out=rg_visible use=attr attribute_column=IDmaxlik

# group the raster maps for 'i.gensig' and 'i.maxlik' to work
i.group group=perma_max subgroup=perma_max
input=band4_refl,cumRAD_152-259,dem

# generate signature file for supervised 'i.maxlik'
i.gensig trainingmap=rg_visible group=perma_max subgroup=perma_max
signaturefile=perma_sig

# perform the supervised classification
i.maxlik group=perma_max subgroup=perma_max signaturefile=perma_sig
output=classification01 reject=reject01

*SIGNATURE FILE*
#
#
2667
0.143949 822710 2716.71
0.00189715
1025.75 6.24661e+09
1.04109 5.55462e+06 23980.3

*ZONAL STATS*
reject_zonal_stats.csv
<http://osgeo-org.1560.x6.nabble.com/file/n5245700/reject_zonal_stats.csv&gt;

*IMAGES*
<http://osgeo-org.1560.x6.nabble.com/file/n5245700/RGB543.jpg&gt;
<http://osgeo-org.1560.x6.nabble.com/file/n5245700/RGB543_masked.jpg&gt;
<http://osgeo-org.1560.x6.nabble.com/file/n5245700/reject_map.jpg&gt;

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/i-maxlik-strange-classification-output-and-reject-map-tp5242179p5245700.html
Sent from the Grass - Users mailing list archive at Nabble.com.