#!/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.56579833 57.39685749 -gcp 10200.0 0.0 25.56068771 57.30846154 -gcp 10200.0 10449.0 25.40017526 57.30910574 -gcp 0.0 10449.0 25.39892009 57.39727769 GX8473/GX_8473_SK_frame_204.jpg GX_8473_SK_frame_204.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1017.818115234375 560.7271728515625\n1029.0 1261.3635864257812\n557.7272644042969 1271.4545288085938\n509.181884765625 2800.3635864257812\n223.09085083007812 3276.2728271484375\n371.9996337890625 9405.818115234375\n893.454345703125 9429.2724609375\n1206.0 9749.454345703125\n1206.0 10259.454711914062\n9049.63623046875 10197.818115234375\n9050.181884765625 9824.181884765625\n9334.36376953125 9410.727172851562\n9916.36376953125 9399.2724609375\n9867.272827148438 456.0" | \ gdaltransform -tps -output_xy GX_8473_SK_frame_204.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8473_SK_frame_204.vrt GX_8473_SK_frame_204.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8473_SK_frame_204.cut.vrt GX_8473_SK_frame_204.xyz