I have downloaded ESA global land cover tiff file and opened it with QGIS 3.6. To measure Africa separetly I used polygon file of this continent as a mask. I got the result that total area of Africa is 29882300 km2 using r.report plugin. Africa is 30370000 km2 reported in Wikipedia. Why did I get this distinction and how can I reduce it? Difference is 487700 km2. I think this divergence in values is unacceptable.
Geographic vs. Projected Coordinate Systems
The CRS (Coordinate Reference System) of the files you are using is EPSG:4326, which is the identifier of the plain WGS84 in EPGS's nomenclature.
Since WGS84 is a geographic coordinate system (aka latitude-longitude), your files are not projected: a geographic coordinate system in fact does not "speak" km2, but only "understands" angles (and local distance from the Datum center, of course).
To calculate areas and distances in meters/km/miles, you first have to project the raster into a projected coordinate system, for example any
WGS 84 / UTM xx. Which actually means "Universal Transverse Mercator (projection based on) WGS 84 (Datum)".
In your specific case, since you are measuring areas over the whole African continent, you need a projection which maintains equal areas.
I would suggest
Africa_Albers_Equal_Area_Conic which in QGIS is named also
Other projections might seem nice, because they resemble more closely the idea of Africa we have, but areas measurements would be way off.
To reproject the raster file:
- Right-click on the raster ->
- select a projected CRS (best if you choose the appropriate UTM),
- save, and you will have the projected raster added to the layer list
- make sure your project is also in the same projected CRS
- now you can measure/calculate areas in km2