#!/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.50078129 57.3999283 -gcp 10200.0 0.0 25.50694313 57.31186131 -gcp 10200.0 10449.0 25.34596997 57.30682658 -gcp 0.0 10449.0 25.33389753 57.39555644 GX8473/GX_8473_SK_frame_203.jpg GX_8473_SK_frame_203.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1028.7271728515625 469.09075927734375\n1024.3634033203125 1171.0908508300781\n622.3634033203125 1178.1817932128906\n543.2728271484375 2888.181884765625\n242.7271728515625 3311.9998168945312\n351.2728271484375 9274.908782958984\n860.1815185546875 9293.454345703125\n1186.9090576171875 9577.090942382812\n1177.0911254882812 10136.727172851562\n9082.909240722656 10126.909057617188\n9072.545288085938 9669.272827148438\n9439.090576171875 9308.727172851562\n9939.272827148438 9293.454711914062\n9897.818115234375 294.5453796386719" | \ gdaltransform -tps -output_xy GX_8473_SK_frame_203.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8473_SK_frame_203.vrt GX_8473_SK_frame_203.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8473_SK_frame_203.cut.vrt GX_8473_SK_frame_203.xyz