#!/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 24.0681093 56.9832734 -gcp 21414.0 0.0 24.11077719 57.07983111 -gcp 21414.0 21975.0 24.28372398 57.05377216 -gcp 0.0 21975.0 24.24502677 56.96384735 GX2206/GX_2206_SK_frame_54.jpg GX_2206_SK_frame_54.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "450.0 2868.0\n444.0 10230.0\n756.0 10512.0\n786.0 11952.0\n462.0 12282.0\n402.0 19380.0\n21411.0 19572.0\n21384.0 3030.0" | \ gdaltransform -tps -output_xy GX_2206_SK_frame_54.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2206_SK_frame_54.vrt GX_2206_SK_frame_54.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2206_SK_frame_54.cut.vrt GX_2206_SK_frame_54.xyz