#!/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.33816338 57.07201436 -gcp 14322.0 0.0 25.49765825 57.07860396 -gcp 14322.0 14718.0 25.50961018 56.99204119 -gcp 0.0 14718.0 25.35223961 56.98346034 GX220/GX_220_SK_frame_578.jpg GX_220_SK_frame_578.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1872.0 407.94651810584946\n12912.0 459.0\n13632.0 14016.0\n1680.0 14207.986629526464" | \ gdaltransform -tps -output_xy GX_220_SK_frame_578.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_220_SK_frame_578.vrt GX_220_SK_frame_578.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_220_SK_frame_578.cut.vrt GX_220_SK_frame_578.xyz