#!/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.85507582 57.50833393 -gcp 16026.0 0.0 22.81463842 57.48142491 -gcp 16026.0 15777.0 22.76374245 57.50338372 -gcp 0.0 15777.0 22.80595012 57.5301603 GX18588/GX_18588_SK_frame_63.jpg GX_18588_SK_frame_63.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "936.0 1779.0\n15312.0 1296.2005571030638\n15312.0 11302.71643454039\n984.0 11470.743175487465" | \ gdaltransform -tps -output_xy GX_18588_SK_frame_63.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_18588_SK_frame_63.vrt GX_18588_SK_frame_63.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_18588_SK_frame_63.cut.vrt GX_18588_SK_frame_63.xyz