#!/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 23.21132183 57.28314855 -gcp 16671.0 0.0 23.15145493 57.26819619 -gcp 16671.0 16227.0 23.12587738 57.30041334 -gcp 0.0 16227.0 23.18668842 57.31532944 GX18588/GX_18588_SK_frame_45.jpg GX_18588_SK_frame_45.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "801.0 8727.0\n1008.0 8571.0\n1029.0 7542.0\n792.0 7392.0\n828.0 1866.0\n2220.0 1842.0\n2202.0 630.0\n7650.0 606.0\n7785.0 795.0\n8826.0 789.0\n8967.0 597.0\n15681.0 645.0\n15759.0 7443.0\n15576.0 7566.0\n15555.0 8598.0\n15765.0 8739.0\n15750.0 15198.0\n10491.0 15213.0\n10479.0 15522.0\n8973.0 15546.0\n8784.0 15345.0\n7752.0 15342.0\n7560.0 15537.0\n3789.0 15516.0\n3798.0 13815.0\n786.0 13809.0" | \ gdaltransform -tps -output_xy GX_18588_SK_frame_45.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_18588_SK_frame_45.vrt GX_18588_SK_frame_45.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_18588_SK_frame_45.cut.vrt GX_18588_SK_frame_45.xyz