#!/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 24.03514644 56.66327268 -gcp 14376.0 0.0 24.04903475 56.63574553 -gcp 14376.0 14082.0 24.00207156 56.6273837 -gcp 0.0 14082.0 23.98469102 56.65518569 GX4471/GX_4471_R_SK_frame_565.jpg GX_4471_R_SK_frame_565.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "456.0 1655.9732590529247\n14088.0 1680.0802228412258\n13968.0 12648.04011142061\n432.0 12624.106963788301" | \ gdaltransform -tps -output_xy GX_4471_R_SK_frame_565.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4471_R_SK_frame_565.vrt GX_4471_R_SK_frame_565.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4471_R_SK_frame_565.cut.vrt GX_4471_R_SK_frame_565.xyz