You just need to add the .tif file to your QGIS map as a raster. The other files are supporting information for things like georeferencing the image (where it's supposed to be in the world), image pyramids (to load faster at smaller scales where full detail isn't needed), and values and possibly attributes to go along with each pixel (normally rasters are simply a numeric value for each pixel/grid cell, but they can have additional attributes with some formats).
The data you are trying to use appears to only be available in raster formats. Raster does not have 'layers' - it is a continuous grid of cells with each cell holding a value. In your case, each cell is given one of 13 values to represent the vegetation type. While you could separate out each of the values to its own raster and set the other cells to 'no data', it sounds like what you are really after is the data in vector format. This will require raster to vector conversion of the tif you download.
Once you follow that process, you will have polygons for each area of distinct landcover with an attribute of the type (as they keyed value). Note it still won't be separate layers - you can control which types are displayed and how, but they are all still part of the same layer. You could then separate them out into separate vector layers if you truly need to by selecting all of one type and exporting to a different file, but depending on how you plan to use the data that is probably not necessary.
I tried the following with a GTiff image I split into R, G and B bands in QGIS:
wd = "C:\\Users\\Manuel\\Desktop\\test"
import rasterio, os
R = os.path.join(wd, "xR.tif")
B = os.path.join(wd, "xB.tif")
output = os.path.join(wd, "out.tif")
with rasterio.open(R) as f:
red = f.read()
profile = f.profile
with rasterio.open(B) as f:
blue = f.read()
profile["dtype"] = "float64"
result = ((red**2)+(blue**2))/(blue)
with rasterio.open(output, 'w', **profile) as dst:
dst.write(result)
This produced the desired output. Note that my original image has RGB values in [0, 255] rather than in [0, 1]; hence, the dtype
value of profile
was uint8
in the single-band GTiffs and the calculation resulted in floats, which is why I added the line profile["dtype"] = "float64"
to have the correct dtype
to write the output (maybe useful for some reader).
Since this part appears to work, I assume you lost the geoinformation when you split the original image into R, G, B, alpha bands? This should be no problem, since you could simply obtain the profile
from the original GTiff instead of the red band. They should only differ in the number of bands, which can be fixed easily:
with rasterio.open(PATH_TO_ORIGINAL_GTIFF) as f:
profile = f.profile
# set the number of bands in the extracted information to 1
profile["count"] = 1
Complete:
import rasterio
with rasterio.open('path/to/Original_4_channel.tif') as f:
profile = f.profile
# set the number of bands to 1
profile["count"] = 1
# [INSERT WHAT EVER CODE YOU USED TO GET THE SINGLE R, G AND B CHANNELS HERE]
# e.g. load the image as img and run
# (red, green, blue, alpha) = np.transpose(img, axes = (2,0,1))
with rasterio.open('path/to/Red_channel.tif') as f:
red = f.read()
with rasterio.open('path/to/Blue_channel.tif') as f:
blue = f.read()
result = ((red**2)+(blue**2))/(blue)
with rasterio.open('path/to/Output.tif', 'w', **profile) as dst:
dst.write(result)
Edit
It was not part of your original question. Nevertheless, I included a way to get the separate raster channels before doing the calculations. This is a complete script that just takes the directory and file name of the original 4-channel GTiff image.
wd = "/path/to/your/GTiff_file"# just the folder without the filename
import rasterio, os
import numpy as np
img_path = os.path.join(wd, "INPUT_FILE_NAME.tif")# filename goes in here
out_path = os.path.join(wd, "OUTPUT_FILE_NAME.tif")
with rasterio.open(img_path) as f:
profile = f.profile
R = f.read(1)
G = f.read(2)
B = f.read(3)
a = f.read(4)
profile["count"] = 1
profile["dtype"] = "float64"
result = ((R**2)+(B**2))/(B)
result = np.expand_dims(result, axis=0)
with rasterio.open(out_path, 'w', **profile) as dst:
dst.write(result)
Best Answer
You could use these two steps:
Use the tool Raster pixels to points
Processing Toolbox > Vector creation > Raster pixels to points
Use Add X/Y fields to layer on the points layer
Processing Toolbox > Vector table > Add X/Y fields to layer