#!/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.84032573 57.40055451 -gcp 10200.0 0.0 25.85320659 57.31411438 -gcp 10200.0 10449.0 25.6951781 57.30674 -gcp 0.0 10449.0 25.67934555 57.39261676 GX8473/GX_8473_SK_frame_210.jpg GX_8473_SK_frame_210.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "986.181884765625 665.4545288085938\n994.909423828125 1435.6364135742188\n440.72735595703125 1466.7273559570312\n398.181884765625 3220.3641357421875\n427.63623046875 9528.0\n999.2728271484375 9598.363403320312\n1260.5454711914062 10008.0\n1275.2728271484375 10446.0\n9026.181884765625 10446.0\n9036.0 9904.909423828125\n9307.09130859375 9529.63623046875\n9833.454345703125 9488.181518554688\n9790.909057617188 590.1817932128906" | \ gdaltransform -tps -output_xy GX_8473_SK_frame_210.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8473_SK_frame_210.vrt GX_8473_SK_frame_210.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8473_SK_frame_210.cut.vrt GX_8473_SK_frame_210.xyz