#!/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 25.1869734 57.29506925 -gcp 15147.0 0.0 25.19684315 57.20617605 -gcp 15147.0 14211.0 25.04337788 57.20120156 -gcp 0.0 14211.0 25.03249884 57.28896425 GX10508/GX_10508_SK_frame_307.jpg GX_10508_SK_frame_307.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1464.0 1428.0\n14880.0 1068.0\n14748.0 12744.0\n1428.0 12612.0" | \ gdaltransform -tps -output_xy GX_10508_SK_frame_307.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10508_SK_frame_307.vrt GX_10508_SK_frame_307.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10508_SK_frame_307.cut.vrt GX_10508_SK_frame_307.xyz