1

I have vector data with field (id,name) and image GeoTIFF format, this two data of the same place. I want to add name data to each pixel corresponds. how to do it when I click to any pixel give me the name corresponds?

3 Answers 3

1

Use the identify tool: click the icon, then right click on the map canvas and select Identify all. The Identify Results panel on the right will show you the values form the raster and the polygon:

enter image description here

11
  • Thank you so much, that for idetifying 2 layer vector and raster in same time what i want it's to add data vector in to metadata raster, like your exemple when u click just to raster i wnat to see also data id is 2
    – resuk
    Dec 29, 2021 at 16:58
  • 1
    I'm not sure if there is a misunderstanding: raster data does not have an attribute table, you cant "add" data to each pixel, if that is what you mean?
    – Babel
    Dec 29, 2021 at 17:01
  • yes exactly give data to each pixel if i have vector with 2 polygones(id=1 and id=5)in raster data i will find all pixel scorrespand of polygone 1 are id=1 and pixels correspand of polygone 2 are id=5)
    – resuk
    Dec 29, 2021 at 17:03
  • As I sayed, it is not possible to "attach" data to each pixel. Rasters do not work like vectors. What you can do (but I'm not sure if that is what you want): Rasterize the polygons. In this way, you create a new raster layer with the pixels corresponding to the attribute value you set, see: i.sstatic.net/fkY2p.png
    – Babel
    Dec 29, 2021 at 17:08
  • yes i rasterize it but the raster like you say doen't keep attribute table for each pixel
    – resuk
    Dec 30, 2021 at 8:10
1

There are tools Raster pixels to points and Raster pixels to polygons in the QGIS Processing toolbox. With these tools you can can convert your raster data into vector data and then you can add your attributes to the features.

Another approach is to add a new band to the raster image and categorize the values of the extra band to correspond with the IDs of your polygons. It is a bit more complicated but doable with GDAL command line utilities.

1
  • the second approche which i want exactly, have code or some documentation to realize that
    – resuk
    Dec 30, 2021 at 16:23
0

Finally I found the solution and I want to share it with you if anyone has the same problem. You should use this option: iterate over this layer to split by each polygon in vector layer like this caption

enter image description here

1
  • 1
    If your problem is solved, please accept this as an answer.
    – Padmanabha
    Dec 31, 2021 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.