7

I'm looking to classify regions on a map by the amount of light pollution in the area. I have the varied intensities (0 through 60) plotted using a color map, but is there anyway that instead of a spectrum of colors I can have the numerical output instead?

So in place of the different colors of blue as shown in the screen shot below, I would be able to see different numbers inside every pixel on the map.

Color per Pixel Example

If I could even get GIS to display the 'value' or 'label' rather than the 'color' that would be everything I'm asking for.

Layer Properties Example

I feel like the solution should be easy, but I'm pretty stuck.

  • 1
    This may make a huge file, have you tried to convert the raster layer to vector polygon (or centroid point layer) and then set a scaled label on the value field/column? – artwork21 Apr 26 '16 at 16:26
  • 2
    Would you want every pixel labelled? You could use Vector > Research Tools > Random Points. You could then grab the attribute of the cell beneath it to label the point. That'd give a general overview in random locations. An issue being inherent in randomness that you'll get clusters and sparse patches. Alternatively you can use regular points. You can use "Add Grid Values to Points" processing tool as mentioned here: gis.stackexchange.com/a/3545/73835 – Knightshound May 26 '16 at 14:27
2

This can be done by converting the raster data into point shapefile, but I could not find a correct tool in QGIS, so I used a workaround method to convert the raster data into a text file using the GRASS tool of r.out.xyz, then you can import that text file as point data using Add delimited text layer. Here is how it works:

  • I have the following raster data, which is just a small subset:

enter image description here

  • I used GRASS tool: r.out.xyz - Exports a raster map as a list of x,y,z values into an ASCII text file, used comma as a Field separator, and saved the text file into the hard disk:

enter image description here

  • I used Add delimited text layer and used comma as the separator:

enter image description here

  • I Used Show Labels for this layer based on the field_3 which contains the z values of (Raster cell values). To make it efficient, I restricted labels to be shown at maximum scale of 5000. A value higher than 5000 makes the labels disappear.

  • Then hide the point symbol using Style -> No Symbols:

enter image description here

  • Here is the output:

enter image description here

But frankly speaking this will produce a huge text file. The size of the above text file is about 11.5 megabyte and the image is small. This makes rendering labels may take some time depending on the RAM of your computer.

  • @ahmadhanb, your answer is explicitly awesome – Taras Oct 19 '18 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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