#!/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.11532953 56.97918388 -gcp 21414.0 0.0 24.16212024 57.07595196 -gcp 21414.0 21975.0 24.33237791 57.04962428 -gcp 0.0 21975.0 24.29536343 56.9593322 GX2206/GX_2206_SK_frame_53.jpg GX_2206_SK_frame_53.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "558.0 3276.0\n573.0 10281.0\n921.0 10545.0\n939.0 11919.0\n582.0 12222.0\n576.0 18804.0\n21411.0 18780.0\n21372.0 2964.0" | \ gdaltransform -tps -output_xy GX_2206_SK_frame_53.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2206_SK_frame_53.vrt GX_2206_SK_frame_53.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2206_SK_frame_53.cut.vrt GX_2206_SK_frame_53.xyz