#!/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 27.06288815 57.42623919 -gcp 21306.0 0.0 27.04946637 57.41301498 -gcp 21306.0 20931.0 27.02472568 57.42016208 -gcp 0.0 20931.0 27.0384264 57.43368979 GX3778/GX_3778_SD_frame_182.jpg GX_3778_SD_frame_182.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "243.75 14451.0\n270.0 11496.0\n627.0 11172.0\n588.0 9786.0\n418.5 9700.5\n298.5 9576.0\n303.0 6504.0\n318.0 4677.0\n354.0 1683.0\n2310.0 1662.0\n2412.0 1107.0\n2385.0 90.0\n10029.0 162.0\n10296.0 363.0\n11703.0 363.0\n11910.0 210.0\n21300.0 216.0\n21303.0 9930.0\n21231.0 9999.0\n21178.5 10395.0\n21157.5 10962.0\n21244.5 11358.0\n21303.0 11434.5\n21303.0 20928.0\n2298.0 20862.0\n2322.0 20100.0\n2286.0 19863.0\n2244.0 19624.5\n2157.0 19483.5\n2074.5 19353.0\n1876.5 19158.0\n1689.0 19032.0\n1321.5 18916.5\n741.0 18919.5\n199.5 18942.0" | \ gdaltransform -tps -output_xy GX_3778_SD_frame_182.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_3778_SD_frame_182.vrt GX_3778_SD_frame_182.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_3778_SD_frame_182.cut.vrt GX_3778_SD_frame_182.xyz