#!/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 26.00576032 57.40113014 -gcp 10200.0 0.0 26.01642869 57.31447619 -gcp 10200.0 10449.0 25.85681482 57.30929387 -gcp 0.0 10449.0 25.84632787 57.39510779 GX8473/GX_8473_SK_frame_213.jpg GX_8473_SK_frame_213.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1143.818115234375 418.9091491699219\n1142.7271728515625 1148.7277221679688\n655.6364135742188 1168.9090576171875\n608.1817016601562 3051.818115234375\n404.181884765625 5008.36376953125\n488.181884765625 9329.453979492188\n1059.818115234375 9330.0\n1285.63623046875 9454.909057617188\n1419.2726440429688 9805.636596679688\n1412.1820678710938 10164.545654296875\n9214.362670898438 10088.726806640625\n9202.909423828125 9624.000366210938\n9491.999267578125 9265.63623046875\n10072.90869140625 9242.7275390625\n9891.273193359375 304.3636779785156" | \ gdaltransform -tps -output_xy GX_8473_SK_frame_213.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8473_SK_frame_213.vrt GX_8473_SK_frame_213.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8473_SK_frame_213.cut.vrt GX_8473_SK_frame_213.xyz