#!/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 3926.175343020347 4985.92520203137 26.52021825 57.16606756 -gcp 18977.931327662314 3863.8709651403315 26.53441787 57.10675638 -gcp 18678.035997280615 19758.381512782762 26.41972661 57.10409428 -gcp 2640.6543131480157 17142.73490261315 26.43097579 57.16829811 GX10514/GX_10514_SK_frame_461.jpg GX_10514_SK_frame_461.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1008.0 2931.0\n20496.0 2832.0267409470753\n20232.0 20136.467966573815\n744.0 19800.066852367687" | \ gdaltransform -tps -output_xy GX_10514_SK_frame_461.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10514_SK_frame_461.vrt GX_10514_SK_frame_461.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10514_SK_frame_461.cut.vrt GX_10514_SK_frame_461.xyz