2

So I need to include the extent of a river into my map, but only have a raster file that shows the outline of the river with a blank (white) background:enter image description here

Is there any way to crop this file so that my result is a raster which includes only the river without the white background so that I can put the layer above for example a ortho and still see the ortho with the river on top?

Alternatively, a raster to vector conversion should work as well, if possible?

2

I would use gdal_translate to add a NODATA value to the raster file. The exact syntax will depend on whether your image is RGB or paletted. For the RGB case, look at this answer. If it's paletted, you can use gdalinfo to get the color indices, then just use

gdal_translate -a_nodata <white_index> src_file out_file

where you substitute the white_index value for the bracketed term

1

because you have the river with white background.
Convert the raster to binary (b,w) and the raster to vector conversion will be very easy.
Using the tool mentioned in comments you should have the solution.

1

You could make the white color in your raster transparent. From the raster layer's properties dialog, select the "Transparency" tab. This tab allows you to add additional transparent colors to your layer. The easiest way to do this is to click the "Add values from display" button on the right (cursor with question mark icon). Then, click one of the white areas in your layer. This will add a new transparent value to the list. Click OK, and all the white areas should become transparent.

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.