#!/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.78420986 57.40208001 -gcp 10200.0 0.0 25.7990332 57.3160921 -gcp 10200.0 10449.0 25.64210545 57.30607726 -gcp 0.0 10449.0 25.62094233 57.39296456 GX8473/GX_8473_SK_frame_209.jpg GX_8473_SK_frame_209.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1210.6363220214844 827.4545288085938\n1201.0908966064453 1525.0908508300781\n655.9090805053711 1573.0909423828125\n634.36376953125 3189.8182983398438\n376.90924072265625 3623.4547119140625\n462.0 9667.63623046875\n1029.2724609375 9660.545654296875\n1420.36376953125 9998.726806640625\n1412.181884765625 10446.0\n9266.181518554688 10446.0\n9267.81884765625 9969.818115234375\n9520.909423828125 9607.63623046875\n10058.726806640625 9605.454711914062\n10007.454345703125 651.2728271484375" | \ gdaltransform -tps -output_xy GX_8473_SK_frame_209.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8473_SK_frame_209.vrt GX_8473_SK_frame_209.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8473_SK_frame_209.cut.vrt GX_8473_SK_frame_209.xyz