[Qgis-user] Generating black white from RGB landsat using Raster Map calculator?

Michel Stuyts michel.stuyts at edegem.be
Wed Jan 17 06:33:03 PST 2018


Chas,

If I have a color GEOTIFF and I want to show or save it as a grayscale GEOTIFF, I use one of these 2 solutions. Depending on the control you want on the color to grayscale conversion it might also be a solution for you.


Solution 1:
If the only thing you want to do is show a colour geotiff in grayscale, you can just change the properties of the layer. In the layer properties you go to the tab “Style”. Under “Color rendering” you will find the option “Grayscale”. By default the option will be set to “Off”, but you can change it to turn grayscale on. Try one of the three options to see what fits your image best.  After that you can also change the values of “Brightness” or “Contrast” to get the best result.

This way you won’t change anything in your source file and it won’t save a grayscale tiff, but it will just show your raster file as grayscale in QGIS.

Solution 2:
If you want to end up with a geotiff file that has the same information in grayscale I usually use some graphical software in the process, but for that you can’t use a GeoTiff, because you would loose the georeference information of the file. Therefore I use the following steps:

1.       Save your geotiff file as TIFF-file with a TFW file:

a.       Right click on your source geotiff file in the layers panel.

b.       Select Save As…

c.       Select Rendered image as Output Mode

d.       Select Gtiff as format

e.       Deselect “Add saved file to map”

f.        Under “Create Options”  click on the + button to add an option. For the newly added option you have to type TFW as “Name” and YES as “Value” (double click in the newly created Option cell to type in it).

g.       Click on the “Browse…” button to select a name and location for your grayscale TIFF file.

h.       Click on the “OK” button

2.       Open the newly created TIFF file in graphical software like XnView, IrfanView or GIMP. Change the image in that software to grayscale and save the file.

3.       Add the newly created TIFF file back to QGIS

4.       Save your newly created TIFF file as a GeoTIFF file:

a.       Right click on your newly created TIFF file in the layers panel.

b.       Select Save As…

c.       Select Rendered image as Output Mode

d.       Select Gtiff as format

e.       Click on the “Browse…” button to select a name and location for your grayscale GEOTIFF file.

f.        Click on the “OK” button

Michel




Van: Qgis-user [mailto:qgis-user-bounces at lists.osgeo.org] Namens Chas Sheen
Verzonden: woensdag 17 januari 2018 14:33
Aan: 'Micha Silver' <tsvibar at gmail.com>; qgis-user at lists.osgeo.org
Onderwerp: Re: [Qgis-user] Generating black white from RGB landsat using Raster Map calculator?

Mike,
So everything in the capture below of the Raster calculator should work? I cannot find any output.
I’m in Perth, Australia so home now and away from the office and QGIS, but would like to get it working tomorrow.
How do apply a grayscale to a raster? As I said, I’m new to QGIS
Chas Sheen

From: Micha Silver [mailto:tsvibar at gmail.com]
Sent: Wednesday, January 17, 2018 8:39 PM
To: Chas Sheen <chassheengeo at gmail.com>; qgis-user at lists.osgeo.org
Subject: Re: [Qgis-user] Generating black white from RGB landsat using Raster Map calculator?

Hello Chas
On 01/17/2018 01:52 PM, Chas Sheen wrote:
Richard,

I should have made my initial query clearer.
I am trying to output a black and white geotiff.
It's still not clear what you are asking. AFAIK, there's no such thing as a "black and white geotiff". You can apply any color table you want to any raster. You can apply a gray scale to any of the landsat bands.

If you are trying to create a new raster from the three RGB bands using some expression, that should work. You can use either of three tools: the built in QGIS raster calculator, or thru the Processing toolbox there's SAGA Raster calculus and the GRASS module r.mapcalculator.

Again, none of this has anything to do with coloring. After running the raster calculator, you can color the result with a gray scale color table, a red color table, or any other color ramp you choose.


Have split the original (landsat) image into RGB images.
When I apply the expression in the capture below, and hit run, nothing is saved to the results directory.
I’m assuming that my expression or something else in the raster calculator is wrong?
The final product that I’m after is a xyz grid where z is the black-white amplitude…which I think should be relatively easy (?) once I have the black-white image.
After you running the calculator expression, then you can save the result in many formats, including gridded XYZ, ArcINFO ASCII, or many others, using the gdal_translate tool. This is under the Raster->Conversion menu.


Chas Sheen
0448017282

From: Richard McDonnell [mailto:richard.mcdonnell at opw.ie]
Sent: Wednesday, January 17, 2018 7:13 PM
To: Chas Sheen <chassheengeo at gmail.com><mailto:chassheengeo at gmail.com>; qgis-user at lists.osgeo.org<mailto:qgis-user at lists.osgeo.org>
Subject: Re: [Qgis-user] Generating black white from RGB landsat using Raster Map calculator?

Chas,
Two options for splitting RGB into separate images in QGIS.

  1.  Semi-Automatic Classification Plugin, Preprocessing, Split Raster Bands
  2.  Grass r-rgb (Processing Toolbox)
Any one of these tools will split the Raster for you easy enough
Regards,

Richard
On 17/01/2018 00:48, Chas Sheen wrote:
I split the image into R, G, B
Worked out in QGIS wher the Raster map calculator is.
Run...several times
No result foud in Results Directory. It runs quickly then refreshes inputs and logs to blanks.
I'm new to QGIS....so have probably left out something basic.
Any clues

[Displaying image.png]




_______________________________________________

Qgis-user mailing list

Qgis-user at lists.osgeo.org<mailto:Qgis-user at lists.osgeo.org>

List info: https://lists.osgeo.org/mailman/listinfo/qgis-user

Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

--
Richard McDonnell
GIS Specialist PgD GIS AssocSCSI
OPW FRM Data Management
52 Stephens Green, Dublin 2.
TEL: 01 6476543
[Afbeelding verwijderd door afzender.]<http://www.opw.ie/>


Email Disclaimer: http://www.opw.ie/en/disclaimer/



_______________________________________________

Qgis-user mailing list

Qgis-user at lists.osgeo.org<mailto:Qgis-user at lists.osgeo.org>

List info: https://lists.osgeo.org/mailman/listinfo/qgis-user

Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


--

Micha Silver

Ben Gurion Univ.

Sde Boker, Remote Sensing Lab

cell: +972-523-665918
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20180117/a081753a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 35456 bytes
Desc: image001.png
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20180117/a081753a/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.jpg
Type: image/jpeg
Size: 1441 bytes
Desc: image003.jpg
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20180117/a081753a/attachment.jpg>


More information about the Qgis-user mailing list