11

I have a raster topographic map, i.e. white background and black contour lines, houses, roads and so on. I want to make transparent the white background, so if I overlap the topographic map to an aerial photo, I see only contour lines, houses and other elements atop the photos.

In ArcGIS this operation is trivial. How can I do it on QGIS 1.8.0?

I explored many forums but I didn't find the answer. The solution is not the command "transparency" on the property window, because that command makes everything transparent.

4 Answers 4

10
  1. Right-Click Layer Properties and select Transparency tab. enter image description here
  2. You would have a default Row in the transparency pixel list. Delete that Row(Use Icon 3)
  3. If you just have to make the White part transparent, Create a new Row(Use Icon1). Enter 255,255,255 for Red,Green and white and Set 100 for percent transparent column.
  4. Click Apply and you are done.

Some sample results.. enter image description here

enter image description here

Additionally, if you want to make any other color on the raster transparent, You can click the Icon2, This would ask you to select a pixel on the raster using mouse. This might make QGIS go minimized for some weird reason, but you can restore it from the taskbar. Then click the color on the raster which you want to make transparent. It would add a new row for that color and make that color transparent for the raster.

1
  • Is there anyway to make this manual process automatically for white and black color (255 and 0). so each time when I insert a new raste image (tif file), it will auto become transparent?
    – Xianlin
    Commented Nov 21, 2013 at 6:01
1

Open the Layer Properties of the image, go to Colormap, set the colorinterpolation to 'exact', delete the white entry (0.0000) and you are done.

0

I struggled to get this to work for awhile too, and my conclusion is this is currently broken in qgis. I'll show you why I think that:

  1. Open up your qgis project in a text editor.
  2. Scroll down to near the bottom, where you'll see something like:

    <Gui>
        <SelectionColorBluePart type="int">0</SelectionColorBluePart>
        <CanvasColorGreenPart type="int">0</CanvasColorGreenPart>
        <CanvasColorRedPart type="int">0</CanvasColorRedPart>
        <SelectionColorRedPart type="int">255</SelectionColorRedPart>
        <SelectionColorAlphaPart type="int">255</SelectionColorAlphaPart>
        <SelectionColorGreenPart type="int">255</SelectionColorGreenPart>
        <CanvasColorBluePart type="int">0</CanvasColorBluePart>
    </Gui>
    

    There are color components for the canvas for RGB, and for the selection for RGB+alpha. Notice that while there is SelectionColorAlphaPart there is no corresponding CanvasColorAlphaPart tag on the canvas.

    These seem to correspond to the colors set when you use

    Settings -> Options -> Default Map Appearance in the menu.

  3. So, as an experiment, let's add a transparency tag in the same format as the rest of the tags. Insert a CanvasColorAlphaPart to the bottom:

    <Gui>
        <SelectionColorBluePart type="int">0</SelectionColorBluePart>
        <CanvasColorGreenPart type="int">0</CanvasColorGreenPart>
        <CanvasColorRedPart type="int">0</CanvasColorRedPart>
        <SelectionColorRedPart type="int">255</SelectionColorRedPart>
        <SelectionColorAlphaPart type="int">255</SelectionColorAlphaPart>
        <SelectionColorGreenPart type="int">255</SelectionColorGreenPart>
        <CanvasColorBluePart type="int">0</CanvasColorBluePart>
        <CanvasColorAlphaPart type="int">0</CanvasColorAlphaPart>
    </Gui>
    
  4. On my machine at least, when I load this back in, there is still no alpha to the background. So even when set externally, qgis fails to recognize transparency in a background layer.

Here are two related bug reports tracking that this had been an issue at one time---the first is marked closed, and the second is unassigned:

-1

Right-Click Layer >> Properties >> Style >> and select "Inverted Polygons"

1

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.