#!/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 2404.5521120876037 4505.566987482467 24.49027419 57.26339255 -gcp 19409.31201537064 2782.9828857198618 24.47767854 57.33274691 -gcp 20001.637242672005 18551.94599810076 24.59401131 57.33474506 -gcp 1608.2538597830667 17926.966806148477 24.59046006 57.2605843 GX8464/GX_8464_SK_frame_290.jpg GX_8464_SK_frame_290.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "816.0 2735.786072423398\n21072.0 2447.9732590529247\n20976.0 19967.973259052927\n768.0 19728.240668523675" | \ gdaltransform -tps -output_xy GX_8464_SK_frame_290.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8464_SK_frame_290.vrt GX_8464_SK_frame_290.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8464_SK_frame_290.cut.vrt GX_8464_SK_frame_290.xyz