#!/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 20.91959953 56.46234822 -gcp 10986.0 0.0 21.11434937 56.44057613 -gcp 10986.0 10605.0 21.1079961 56.31273981 -gcp 0.0 10605.0 20.84269524 56.33671467 GX18627/GX_18627_SK_frame_11.jpg GX_18627_SK_frame_11.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1200.0 551.8261838440108\n10080.0 575.8662952646237\n9960.0 9254.252924791086\n9312.0 9371.899721448468\n9072.0 9840.0\n1368.0 9792.05348189415" | \ gdaltransform -tps -output_xy GX_18627_SK_frame_11.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_18627_SK_frame_11.vrt GX_18627_SK_frame_11.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_18627_SK_frame_11.cut.vrt GX_18627_SK_frame_11.xyz