#!/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 26.13586307 57.07022386 -gcp 42708.0 0.0 26.13532662 56.98687411 -gcp 42708.0 42837.0 25.98061681 56.98558236 -gcp 0.0 42837.0 25.97784877 57.06940154 GX220/GX_220_SK_frame_589.jpg GX_220_SK_frame_589.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "2352.0 3744.0\n2592.0 37200.0\n39936.0 37440.0\n40368.0 3216.0" | \ gdaltransform -tps -output_xy GX_220_SK_frame_589.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_220_SK_frame_589.vrt GX_220_SK_frame_589.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_220_SK_frame_589.cut.vrt GX_220_SK_frame_589.xyz