#!/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.61524289 57.39600944 -gcp 10200.0 0.0 25.62006561 57.30872906 -gcp 10200.0 10449.0 25.45966597 57.3049479 -gcp 0.0 10449.0 25.45138585 57.39313059 GX8473/GX_8473_SK_frame_206.jpg GX_8473_SK_frame_206.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1081.0909423828125 237.27273559570312\n1067.4545288085938 980.1817016601562\n594.545654296875 992.7271728515625\n540.0 2674.36376953125\n270.0 3225.2728271484375\n332.7271728515625 9169.090942382812\n895.0909423828125 9152.726806640625\n1245.5454711914062 9551.454528808594\n1225.0909423828125 10104.818115234375\n9086.726806640625 9953.454711914062\n9053.455078125 9514.363403320312\n9327.818115234375 9152.181884765625\n9874.909423828125 9121.636596679688\n9918.544921875 207.2728271484375" | \ gdaltransform -tps -output_xy GX_8473_SK_frame_206.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8473_SK_frame_206.vrt GX_8473_SK_frame_206.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8473_SK_frame_206.cut.vrt GX_8473_SK_frame_206.xyz