#!/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 22.57649661 57.78365882 -gcp 10920.0 0.0 22.59128562 57.74876849 -gcp 10920.0 10800.0 22.53281951 57.73642301 -gcp 0.0 10800.0 22.50197411 57.77331811 GX18588/GX_18588_SK_frame_083.jpg GX_18588_SK_frame_083.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "864.0 1515.0\n10224.0 1487.8261838440108\n9984.0 9144.026740947076\n792.0 9264.120334261837" | \ gdaltransform -tps -output_xy GX_18588_SK_frame_083.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_18588_SK_frame_083.vrt GX_18588_SK_frame_083.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_18588_SK_frame_083.cut.vrt GX_18588_SK_frame_083.xyz