NAIP aerial imagery from USGS has all water colored white?

I downloaded some aerial imagery from USGS, at a resolution of 1m at a GEOTIFF. I'm overall happy with it, except for the fact hat the whole image appears somewhat overexposed and the water and shadows are all colored white. I decided to nevertheless push it into resample and see what comes out, but resmaple seems to take some of these white areas as a water mask, and other part sit makes black, so that, overall, the imagery looks terrible in the sim. This makes me think that the strange whiteness is some kind of alpha layer that is included in this GEOTIFF.

I loaded the file into QGIS, and found that in QGIS it is displayed correctly. Moreover, if I convert the GEOTIFF to be Float32 (rather than Byte), it appears with beautiful colors, even if perhaps a little too saturated. However, it doesnt seem that Sbuilderx and other software accepts this type of GEOTIFF nor have I been able to save this GEOTIFF as a simple bmp, to import it separately into sbuilderx and georeference it myself.

So, I was hoping anybody here has encountered a similar issue with NAIP imagery from the USGS? What can I do about it?
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Hi,

Resample doesn't accept geotiffs with floats either, you'll have to use byte.

Most likely you have images with a 4th NIR band included. You will need to remove that first, if you don't use it.
 
See, that's why I come here :) I didn't realize such a layer might exist... What would be the quickest/easiest way to get rid of it? How can I even see there is one...?

EDIT: Just checked the source of the file in QGIS, and indeed there is a fourth band there. It's a layer where the water is completely black, so I'm guessing it's indeed a NIR layer. When I convert the GEOTIFF to Byte, it throws out those values it seems, resulting in the horrible looking GEOTIFF with white water and shadows. I'm not too sure what to do about it though... Any ideas?
 
Last edited:

arno

Administrator
Staff member
FSDevConf team
Resource contributor
The GeoTIFF should be using byte already, so not sure what you mean with converting to byte.

You could use gdal_translate to remove the band with a command like this:

Code:
gdal_translate -b 1 -b 2 -b 3 input.tif output.tif
Or check your INF file for resample. if you don't use the alpha channel there, there should be no problem either.
 
Thanks for your help Arno, but I think I'll need to take a step back here. You must understand that I have no experience at all with GIS software, besides the tiny bit of work I did a few months back on this scenery project. At the time I had no trouble with alpha layers as I was working with elevation data that didn't come with any such stuff. As such, I honestly don't know how to get to gdal commands - I just know they exist and that this is what QGIS uses to do what I tell it to do.

I say converted because at first I had no idea there were so many encoding types for GeoTIFF - I thought 'GeoTIFF is GeoTIFF and that's the end of it'. So when I did those first translations etc in QGIS, I didn't pay attention to whether the file was float32 or byte, and QGIS' default is float32. Hence I later had to convert it back to byte.

In the meantime I found out that the source files come with this NIR/alpha band, and they are encoded as GeoTIFF byte. Then when I merge and clip the imagery (their coverage is otherwise way bigger then I need them to be), everything is fine - but as soon as I save the final merged and clipped image as a GeoTIFF byte file, it becomes all wonky. Even QGIS is not prepared to show me the file the way it's supposed to.

So I had a look at the Band 4, which is the final file is labeled as "Alpha" (the others are Red, Blue and green), and I use a the single-channel gray scale 'style' to show this Alpha band and it looks nothing like it looked before. In the source files, band 4 shows black water - in the clipped and merged files the water has turned white. So I dunno - but it seems like the 'save as' command is doing something bad to Alpha band, and this is screwing up everything down the line. But how I'm going to work with a GeoTIFF file that I can't actually save I have no idea...

And needless to say, I'm terribly confused.

EDIT: I opened up the source files in Photoshop, and indeed there is an Alpha channel there that looks totally different in the saved versions coming out of QGIS. It seems like QGIS is doing something to the files, but I have no idea what it is...

EDIT: Right, another edit. I found that the merge I did was still in float 32. once I did the merge of the original source files but had it output as byte, just doing the merge screwed up the alpha layer. I will perhaps try to get rid of the alpha before doing anything else, but I'm not too sure exactly how to get to the gdal tools...

EDIT: Removing the alpha layer works, but obviously I lose the georeferencing. Doesn't seem I'm able to get it back without a lot of tedious work. There must be an easy way to do this...
 
Last edited:
Finally success! I researched GDAL and the calls you mentioned, Arno. It turns out QGIS 3.2 (which is what I'v;e been using) lost a feature that allowed editing the GDAL calls from the UI. I ended up reverting to QGIS 2.18, where I could do this. Now I could specify, when translating the imagery, to lose the NIR band. Additionally, QGIS 2.18 didn't use float32 as the standard GEOTIFF, rather it sticks with whatever the file already was, and so I was able to get rid of the NIR band, merge, reproject, and clip Now I have exactly what I need for sbuilder and Photoshop. Tonight I'll compile the bgl to see what P3D thinks of it, but I'm feeling hopeful. Thanks for the help Arno!
 
Top