#!/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 22.54802911 57.51912917 -gcp 21369.0 0.0 22.40722714 57.4443781 -gcp 21369.0 21639.0 22.24548075 57.53843238 -gcp 0.0 21639.0 22.4388111 57.60063313 GX13126/GX_13126_SK_frame_67.jpg GX_13126_SK_frame_67.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "396.0 11562.0\n642.0 11286.0\n645.0 10773.0\n369.0 10467.0\n384.0 2250.0\n2262.0 2244.0\n2340.0 960.0\n15759.0 816.0\n15783.0 1641.0\n20448.0 1566.0\n20379.0 19692.0\n20130.0 19797.0\n19953.0 19917.0\n19791.0 20124.0\n19677.0 20391.0\n19626.0 21000.0\n2457.0 21123.0\n2454.0 20307.0\n2286.0 19983.0\n2055.0 19692.0\n1857.0 19560.0\n1440.0 19494.0\n348.0 19500.0" | \ gdaltransform -tps -output_xy GX_13126_SK_frame_67.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_13126_SK_frame_67.vrt GX_13126_SK_frame_67.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_13126_SK_frame_67.cut.vrt GX_13126_SK_frame_67.xyz