roblabs / gdal2tilesp

Enhancements to tile cutter for parallelism and image format support
Other
20 stars 9 forks source link

Feature to skip partial tiles #12

Closed caleb87 closed 5 years ago

caleb87 commented 5 years ago

What would it take to skip edge tiles that are partially blank (and fully blank)?

I'm trying to tile many tifs that overlap, and I don't see how I can get full tiles in the overlap areas. Merging tifs won't work, because the output file will be terabytes in size.

The original gdal2tiles (https://github.com/OSGeo/gdal/blob/master/gdal/swig/python/scripts/gdal2tiles.py) has a part to skip fully blank tiles, but I haven't figured out how to detect partial tiles and implement it into gdal2tilesp yet.

       alpha = alphaband.ReadRaster(rx, ry, rxsize, rysize, wxsize, wysize)

        # Detect totally transparent tile and skip its creation
        if tile_job_info.exclude_transparent and len(alpha) == alpha.count('\x00'.encode('ascii')):
            return

        data = ds.ReadRaster(rx, ry, rxsize, rysize, wxsize, wysize,
                             band_list=list(range(1, dataBandsCount + 1)))
roblabs commented 5 years ago

What would it take to skip edge tiles that are partially blank (and fully blank)?

It sounds like your problem has nothing to do with the gdal2tiles.

Things to consider (whether using this repo or the official OSGeo version)

From the command line help

e.g.
  % gdalbuildvrt doq_index.vrt doq/*.tif
  % gdalbuildvrt -input_file_list my_list.txt doq_index.vrt
caleb87 commented 5 years ago

Rob thanks for the input!

I have a tif with no alpha edges (it's rectangle), but the tiles still produce partial alpha due to the alignment of the tiles.

Original (Scaled down to low quality jpg) test1

Tile Cuts 26219 26234

Map Tiler and gdal2tiles output the same. They skip fully blank tiles (when there are huge alpha areas), but I haven't found a way to skip partial tiles.

BTW I'm using gdal_merge which is working well, but I'll look into gdalbuildvrt.