#!/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.78180152 57.01661531 -gcp 14202.0 0.0 24.59063721 57.02451103 -gcp 14202.0 14040.0 24.62756314 57.12095674 -gcp 0.0 14040.0 24.78525348 57.1095267 GX2206/GX_2206_SK_frame_91.jpg GX_2206_SK_frame_91.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1464.0 323.9933147632312\n12264.0 267.0\n12480.0 13703.986629526464\n1224.0 13776.080222841225" | \ gdaltransform -tps -output_xy GX_2206_SK_frame_91.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2206_SK_frame_91.vrt GX_2206_SK_frame_91.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2206_SK_frame_91.cut.vrt GX_2206_SK_frame_91.xyz