#!/bin/bash GDAL_TILE_PROCESSES=16 GDAL_TILE_ZOOMS=8-14 GDAL_SAMPLING_WARP=cubic GDAL_SAMPLING_TILE=antialias # Create virtual dataset with coordinates gdal_translate -of VRT -a_srs EPSG:4326 -outsize 300% 300% -gcp 0.0 0.0 25.75181901 56.44985392 -gcp 21477.0 0.0 25.79851521 56.44955123 -gcp 21477.0 21171.0 25.79906344 56.42327765 -gcp 0.0 21171.0 25.74997902 56.42343785 GX1443/GX_1443_SD_frame_10.jpg GX_1443_SD_frame_10.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "792.0 2904.0\n744.0 19032.0\n2400.0 19080.0\n2640.0 20784.0\n21264.0 20664.0\n20976.0 2832.0" | \ gdaltransform -tps -output_xy GX_1443_SD_frame_10.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_1443_SD_frame_10.vrt GX_1443_SD_frame_10.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_1443_SD_frame_10.cut.vrt GX_1443_SD_frame_10.xyz