#!/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.62714195 56.65212282 -gcp 14172.0 0.0 24.63111517 56.73655713 -gcp 14172.0 14301.0 24.78040874 56.7350457 -gcp 0.0 14301.0 24.78092372 56.6514998 GX10504/GX_10504_SK_frame_849.jpg GX_10504_SK_frame_849.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "576.0 1320.733740967204\n13776.0 1152.6403557531962\n13680.0 12774.763757643133\n504.0 12654.697053918844" | \ gdaltransform -tps -output_xy GX_10504_SK_frame_849.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10504_SK_frame_849.vrt GX_10504_SK_frame_849.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10504_SK_frame_849.cut.vrt GX_10504_SK_frame_849.xyz