#!/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 24.30430055 57.11342779 -gcp 21498.0 0.0 24.32030797 57.13850398 -gcp 21498.0 21123.0 24.36611588 57.1305439 -gcp 0.0 21123.0 24.3509388 57.104368 GX4196/GX_4196_SD_frame_14.jpg GX_4196_SD_frame_14.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "816.0 1878.0\n2592.0 1800.3476323119778\n2664.0 479.5454038997218\n17592.0 695.211142061281\n17760.0 2328.4545961002786\n21072.0 2352.0534818941505\n20832.0 20807.933147632313\n2472.0 20760.227298050137\n2400.0 19319.65236768802\n864.0 19105.096378830083" | \ gdaltransform -tps -output_xy GX_4196_SD_frame_14.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4196_SD_frame_14.vrt GX_4196_SD_frame_14.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4196_SD_frame_14.cut.vrt GX_4196_SD_frame_14.xyz