I've carefully cut the collar off a set of USGS geotifs and I'd like to run through them with gdal2tiles but producing a vrt that undersands the alpha layer, or having gdal2tiles overlap two source files into one tile is not working. Some things I have tried have made all black pixels transparent. Other attempts rendered the transparent borders on my source files as if they were solid white, so when one tile is made from two adjoining tifs the transparent border from one covers up the useful content of another. Here is my process, maybe someone can tell me a conversion step I'm missing:
- Download regular USGS geotif from Topoquest
- gdal_translate -expand rgba -co COMPRESS=LZW orginal.tif translated.tif
- Open translated.tif in Photoshop, cut off the collar, save.
- gdalcopyproj.py translated.tif prepared.tif
Do that for all of them
- gdalbuildvrt temp.vrt *.tif
- gdal2tiles.py temp.vrt tiles
P.S. I can merge them all smoothly with gdal_warp but on this group of 30 it is making a combined geotiff of 51223 x 65163 and on other sets there will be lots of wasted space when the source tifs are in a diagonal line but gdal_warp will create a rectangular output.
Best Answer
GDAL supports a mask layer, but it also supports a "no data" colour which I tend to use because it cuts the size of the final image down by 25%. So the steps I would use with your data, after cutting off the collar is:
Note, I've put in Ground Control Points (GCPs) and a projection which you'll have to determine empirically. Also note I've assigned pure white to the nodata value.
These images are still not properly georeferenced however, as they still only have GCPs rather than proper coordinates. So you will need to run
gdalwarp
:Note again the explicit setting of the nodata values. This is probably overkill, but it doesn't hurt, and I've had
gdalwarp
ignore what I thought was implicit nodata vales.Next, you need to run
gdalbuildvrt
like you have it, but I usually explicitly specify the nodata values again, to be on the safe side:Edit
This may be closer to what you want:
Finally, you can call
gdal2tiles.py
as you have it.