I am trying to combine several tiles into a single background image. I am using code from here to do the tile retrieval and merging. I've used it before on Aerial Imagery, and it worked great. Now I'm using it on Stamen Terrain tiles, and it's not working.
Specifically, it only reads one channel from RGBA tiles, and the merged image is grayscale with an inconsistent mean value.
I've pulled several adjacent Stamen terrain tiles into a folder (these look to be correct, full-color jpg and tif tiles), and then ran the merge_tiles
method on them.
inputFiles = []
for name in glob.glob(inputTiles):
if 'tif' in name:
src = rasterio.open(name)
array = src.read()
print(array.shape)
inputFiles.append(src)
mergedImage, out_trans = merge(inputFiles)
The array.shape
for every tile is (1, 256, 256)
, but it should have 3 bands for RGB (they actually have 4! even though they are jpgs, but the 4th channel is all 1s). So the problem is not with merging itself, but in reading the Stamen tiles. Using the same code on my previous tileset still correctly reads, merges, and writes the merged tif image.
So does anybody know how to correctly read in these Stamen Terrain jpg tiles using rasterio so that all the channels are detected?