Opened 14 years ago
Closed 5 years ago
#3596 closed enhancement (wontfix)
rfe: gdal2tiles.py skip empty tiles
Reported by: | hamish | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | closed_because_of_github_migration |
Component: | Utilities | Version: | svn-trunk |
Severity: | minor | Keywords: | gdal2tiles |
Cc: |
Description
Hi,
when using gdal2tiles.py with a source image which gets substantially rotated in the gdalwarp, you can end up with entire rows of tiles containing nothing but blank tiles around the edges. It would be nice to skip them.
here's a method I've used in a similar situation in the past:
- check Band stats with gdalinfo by looking at the R,G,B bands and seeing if the (6) max and min values of all three bands are identical. (presumably this fails on large solid greyscale fill...)
It works by stacking the 6 numbers in a line and then running uniq
and testing if there is only 1 number remaining. Presumably this could be done much more cleanly in Python; maybe remove the head -n 3
to take the 4th alpha band into account; or just test to see if the alpha band is 100% transparent across the entire tile?
# check if image is empty CNT=`gdalinfo -mm -noct -nomd "${OUTFILE}.tif" | grep 'Min/Max' | \ cut -f2 -d= | head -n 3 | tr ',' '\n' | uniq | wc -l` if [ "$CNT" -eq 1 ] ; then echo "Skipping blank image ..." \rm "${OUTFILE}.tif" continue fi
thanks, Hamish
Attachments (2)
Change History (5)
by , 10 years ago
Attachment: | gdal2tiles_skipblanks.py added |
---|
follow-up: 2 comment:1 by , 10 years ago
I added my current version of gdal2tiles.py from gdal_1.10.1. I had the same blank tile crashing issue and used the debugger to find out what was going on.
If someone 'diff' s my code against the the original source they can see the changes I made.
Peter
by , 10 years ago
Attachment: | gdal2tiles_skipblanks.patch added |
---|
Patch supporting skipping blank tiles
comment:2 by , 10 years ago
Replying to pwillis:
I added my current version of gdal2tiles.py from gdal_1.10.1. I had the same blank tile crashing issue and used the debugger to find out what was going on.
If someone 'diff' s my code against the the original source they can see the changes I made.
Patch of 1.10.1 vs. Peter's version attached to ticket.
Hamish
comment:3 by , 5 years ago
Milestone: | → closed_because_of_github_migration |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub. If you believe this ticket is still valid, you may file it to https://github.com/OSGeo/gdal/issues if it is not already reported there.
pwillis: Added some code to skip blank tiles (this is being tested)