#!/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.25303555 56.61972861 -gcp 21435.0 0.0 23.26774684 56.6403035 -gcp 21435.0 21444.0 23.30551234 56.63220232 -gcp 0.0 21444.0 23.29066157 56.61107982 GX4471/GX_4471_SD_frame_124.jpg GX_4471_SD_frame_124.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "864.0 2598.0\n21072.0 2255.9732590529247\n21264.0 19871.679108635097\n864.0 19248.401114206128" | \ gdaltransform -tps -output_xy GX_4471_SD_frame_124.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4471_SD_frame_124.vrt GX_4471_SD_frame_124.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4471_SD_frame_124.cut.vrt GX_4471_SD_frame_124.xyz