timwaters / mapwarper

free open source public map georeferencer, georectifier and warper
http://mapwarper.net
MIT License
196 stars 80 forks source link

enable BIGTIFF for large uploads #114

Open timwaters opened 7 years ago

timwaters commented 7 years ago

large uploads can create large tiff files, and gdaladdo fails after successful (but slow) gdalwarp

In that case we need to specify the -co BIGTIFF=YES/IF_NEEDED/IF_SAFER flag to gdalwarp

e.g.

gdal_translate -a_srs '+init=epsg:4326' -of VRT uploadimage.tiff_masked 18559_temp.vrt -gcp 38435.872991098, 10788.36941965, -71.0634568305, 42.3580503963 -gcp 31820.385119204, 27201.856696421, -71.0735392543, 42.339664516 -gcp 33994.143898809, 13851.393154763, -71.0702380792, 42.3546821768 -gcp 33511.597023809, 14582.106994049, -71.0709461823, 42.3538338231 -gcp 11075.465178517, 20957.157103203, -71.1051014319, 42.3466335275 -gcp 11360.397619046, 39256.337202383, -71.104575719, 42.3260617575 -gcp 24421.333035659, 57687.539166748, -71.0847595587, 42.3052091501 -gcp 48760.078273817, 8777.757440479, -71.047704217, 42.3602801238

gdalwarp -rn -dstalpha -srcnodata '17 17 17' -s_srs 'EPSG:4326' 18559_temp.vrt 18559.tif -co TILED=YES -co COMPRESS=LZW -co BIGTIFF=YES/NO/IF_NEEDED/IF_SAFER

created a 5.8G tiff file (With overviews)

timwaters commented 7 years ago

"When creating a new GeoTIFF with no compression, GDAL computes in advance the size of the resulting file. If that computed file size is over 4GiB, GDAL will automatically decide to create a BigTIFF file. However, when compression is used, it is not possible in advance to known the final size of the file, so classical TIFF will be chosen. In that case, the user must explicitly require the creation of a BigTIFF with BIGTIFF=YES if the final file is anticipated to be too big for classical TIFF format. If BigTIFF creation is not explicitly asked or guessed and the resulting file is too big for classical TIFF, libtiff will fail with an error message like "TIFFAppendToStrip:Maximum TIFF file size exceeded"."

We use compression, so may need to need to look at the size of the input file and add that flag where needed.

Does adding BIGTIFF=YES make a difference for smaller files though?

timwaters commented 7 years ago

Asking in #gdal in IRC "that will add a few extra bytes to your file, but generally not in a very significant way"

So we need to look at the input size, and add that if need be.

Need to see what min size tends to result in > 4gb outputs