#!/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.33655063 57.39809239 -gcp 10200.0 0.0 25.33676683 57.30949933 -gcp 10200.0 10449.0 25.17451399 57.30680208 -gcp 0.0 10449.0 25.16757991 57.39616254 GX8473/GX_8473_SK_frame_200.jpg GX_8473_SK_frame_200.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1074.5452880859375 386.181884765625\n1015.090576171875 1093.0910339355469\n561.2728271484375 1128.5454711914062\n536.7275390625 2753.454345703125\n235.63641357421875 3339.818115234375\n335.99981689453125 9161.999725341797\n897.8182983398438 9156.545288085938\n1243.63623046875 9550.909423828125\n1239.2728271484375 10054.909057617188\n9092.181701660156 9933.272827148438\n9059.454345703125 9524.727172851562\n9384.000732421875 9175.63623046875\n9899.999267578125 9136.363403320312\n9883.63623046875 225.81820678710938" | \ gdaltransform -tps -output_xy GX_8473_SK_frame_200.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8473_SK_frame_200.vrt GX_8473_SK_frame_200.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8473_SK_frame_200.cut.vrt GX_8473_SK_frame_200.xyz