5

In my project when raster layers are overlapping a white band appears the edge of the top layer.

How can I remove it and obtain a seamless overlapping of the raster ?

(I have try to built a vrt with those layers but the with bands remained)

I am working with QGIS 2.4

Here is a example of the phenomena (each layer has 10% transparency) white band on overlapping raster

Here is the gdalinfo output of one of the raster Driver: GTiff/GeoTIFF Files: /vdata/scot_009h_georef.tif Size is 5985, 2349 Coordinate System is: GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich",0], UNIT["degree",0.0174532925199433], AUTHORITY["EPSG","4326"]] Origin = (-3.873394354081865,58.119237085214102) Pixel Size = (0.000601740178426,-0.000601740178426) Metadata: AREA_OR_POINT=Area Image Structure Metadata: COMPRESSION=LZW INTERLEAVE=PIXEL Corner Coordinates: Upper Left ( -3.8733944, 58.1192371) ( 3d52'24.22"W, 58d 7' 9.25"N) Lower Left ( -3.8733944, 56.7057494) ( 3d52'24.22"W, 56d42'20.70"N) Upper Right ( -0.2719794, 58.1192371) ( 0d16'19.13"W, 58d 7' 9.25"N) Lower Right ( -0.2719794, 56.7057494) ( 0d16'19.13"W, 56d42'20.70"N) Center ( -2.0726869, 57.4124932) ( 2d 4'21.67"W, 57d24'44.98"N) Band 1 Block=5985x1 Type=Byte, ColorInterp=Red NoData Value=0 Band 2 Block=5985x1 Type=Byte, ColorInterp=Green NoData Value=0 Band 3 Block=5985x1 Type=Byte, ColorInterp=Blue NoData Value=0

underdark
  • 84,148
  • 21
  • 231
  • 413
kFly
  • 859
  • 1
  • 11
  • 27
  • Is it always white? (255,255,255) You can use srcnodata in the building of the VRT. – Michael Stimson Jul 23 '14 at 01:54
  • Can you edit your question and add a gdalinfo report for one of the rasters. – user2856 Jul 23 '14 at 11:21
  • @MichaelMiles-Stimson: Yes, the edge is always white. One borders almost each raster. – kFly Jul 23 '14 at 20:06
  • @Luke: I added gdalinfo output in the question. – kFly Jul 23 '14 at 20:08
  • 1
    Have you tried adding a no data value (perhaps 255, maybe 0) in the raster properties transparency setting? – John Jul 23 '14 at 20:21
  • @johns: Tried and it work. I had a nodata value = 0, otherwise I had in addition to the white edge, a black one. I added 255 to "Additional No Value" and the white edge has disappeared. Is it possible to apply the change to all layer at once ? – kFly Jul 23 '14 at 20:54
  • 1
    This might help: http://gis.stackexchange.com/questions/25023/can-i-change-properties-of-several-layers-simultaneously I know ArcMap has a customization that provides for a default display of background and no data values, but a quick look at my QGIS didn't show that option. Others probably know better. – John Jul 23 '14 at 21:10
  • The nodata value does not seem to be saved in a qml file (style). Therefore multiQML is not helping in my case. – kFly Jul 24 '14 at 00:01

1 Answers1

3

Option 1

You have discovered one option - adding 255 to the "Additional No Value" in Layer Properties/Transparency.

Option 2

Another option is to use a VRT, define 255 as the source nodata value and define 0 as the VRT no data value using gdalbuildvrt.

For example:

gdalbuildvrt -srcnodata 255 -vrtnodata 0 out.vrt in.tif

To do this on all tiffs in a folder, use something like the following (assuming you are using a bash shell on OSX/Linux/Unix based on the path in your gdalinfo output):

for f in *.tif; do gdalbuildvrt -srcnodata 255 -vrtnodata 0 "${f%.*}".vrt "$f";  done

Option 3

A third option that will actually crop the white collars permanently and not turn non-collar white pixels to NoData is the GDAL nearblack utility.

For example:

nearblack -of gtiff -nb 0 -color white -near 0 -o decollar.tif collar.tif

To do this on all tiffs in a folder, use something like the following:

for f in *.tif; do nearblack -of gtiff -nb 0 -color white -near 0 -o "${f%.*}"-decollared.tif "$f";  done

Note "${f%.*}" is bash parameter expansion syntax to get the filename without the extension.

user2856
  • 65,736
  • 6
  • 115
  • 196
  • Actually adding 255 in "Additionnal No Value" in the layer worked only for the individual layer, and in the project overview. When I built the VRT afterwards, the white lines came back. I will try your proposal when I get again access to the computer in 2 weeks. My other concern is by doing this, I alter the content of the raster deleting the real white inside the raster, whereas the white borders are not present in the individual raster but only around the area where 2 rasters overlap, and on the top layer. Is this concern relevant ? – kFly Jul 24 '14 at 21:11
  • @FlyingGman Yes, that's because the "Additionnal No Value" is a per-layer setting. Yes, all white values will be set as NoData. I've edited my question to add another option. – user2856 Jul 24 '14 at 23:59
  • I found the origin of these white border: in the initial jpg scan a fine white border of 45 pixels was included during in the scan process by the machine. After georeferencing, this border is a bit deformed. Once all the files have been georeferenced, it is too time consuming the crop the individual raster and restart the georeferencing. I think your option 3 can work, I need to find a color not present in the raster to fill this border, and set this value to no value as you explained. – kFly Aug 22 '14 at 22:00