#!/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.63058142 57.25926833 -gcp 21600.0 0.0 26.63574768 57.34362833 -gcp 21600.0 23403.0 26.80466889 57.34046346 -gcp 0.0 23403.0 26.80145534 57.25685033 GX8464/GX_8464_SK_frame_253.jpg GX_8464_SK_frame_253.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "498.0 2190.0\n456.0 19224.0\n20976.0 19536.0\n21096.0 2040.0" | \ gdaltransform -tps -output_xy GX_8464_SK_frame_253.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8464_SK_frame_253.vrt GX_8464_SK_frame_253.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8464_SK_frame_253.cut.vrt GX_8464_SK_frame_253.xyz