#!/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 2163.7758721559812 5991.083932419192 25.57230949 57.26758205 -gcp 20344.921291521394 5809.516763548734 25.57461619 57.33821334 -gcp 15620.654466107082 20181.862808382564 25.67796707 57.31845926 -gcp 2075.6032931004734 14855.760150943603 25.63681126 57.26620631 GX8464/GX_8464_SK_frame_272.jpg GX_8464_SK_frame_272.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "336.0 2687.9279639819897\n21096.0 2567.6758379189605\n20880.0 19824.04802401201\n288.0 19656.108054027012" | \ gdaltransform -tps -output_xy GX_8464_SK_frame_272.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8464_SK_frame_272.vrt GX_8464_SK_frame_272.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8464_SK_frame_272.cut.vrt GX_8464_SK_frame_272.xyz