#!/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.5718381 57.39636887 -gcp 10200.0 0.0 25.565272 57.30761144 -gcp 10200.0 10449.0 25.40331104 57.31005108 -gcp 0.0 10449.0 25.40481725 57.39783611 GX8473/GX_8473_SK_frame_205.jpg GX_8473_SK_frame_205.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1028.7271728515625 544.3635864257812\n1012.36376953125 1255.6364135742188\n487.0909423828125 1278.5454711914062\n511.63641357421875 2905.0909423828125\n229.0909423828125 3529.6364135742188\n389.4547119140625 9369.818115234375\n926.7271728515625 9367.090942382812\n1311.2728271484375 9743.455078125\n1316.181884765625 10267.636596679688\n9172.909423828125 10132.63623046875\n9181.909057617188 9565.63623046875\n9497.727172851562 9316.363586425781\n9934.363403320312 9314.181518554688\n9854.181884765625 300.0" | \ gdaltransform -tps -output_xy GX_8473_SK_frame_205.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8473_SK_frame_205.vrt GX_8473_SK_frame_205.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8473_SK_frame_205.cut.vrt GX_8473_SK_frame_205.xyz