#!/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.72379674 57.39903865 -gcp 10200.0 0.0 25.73755111 57.31281905 -gcp 10200.0 10449.0 25.5805668 57.30304781 -gcp 0.0 10449.0 25.5597041 57.39039859 GX8473/GX_8473_SK_frame_208.jpg GX_8473_SK_frame_208.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1074.5453796386719 447.27264404296875\n1069.0909423828125 1149.8184814453125\n583.0909423828125 1220.1821594238281\n544.9090576171875 2810.1820678710938\n243.2728271484375 3526.9092407226562\n354.5452880859375 9290.181884765625\n958.9090576171875 9286.909057617188\n1291.0909423828125 9705.2724609375\n1287.2724609375 10192.909057617188\n9106.909423828125 10101.818115234375\n9137.455078125 9650.181518554688\n9370.909423828125 9324.0\n9948.0 9295.090942382812\n9882.545654296875 315.2728271484375" | \ gdaltransform -tps -output_xy GX_8473_SK_frame_208.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8473_SK_frame_208.vrt GX_8473_SK_frame_208.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8473_SK_frame_208.cut.vrt GX_8473_SK_frame_208.xyz