#!/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.23180044 57.13004135 -gcp 21627.0 0.0 24.25340595 57.15331433 -gcp 21627.0 21252.0 24.29666461 57.14196506 -gcp 0.0 21252.0 24.27468896 57.11795394 GX4196/GX_4196_SD_frame_10.jpg GX_4196_SD_frame_10.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "912.0 2351.8395543175484\n21216.0 2207.7325905292473\n21264.0 20880.722005571028\n2808.0 20928.467966573815\n2532.0 19619.72590529248\n888.0 19428.073537604458" | \ gdaltransform -tps -output_xy GX_4196_SD_frame_10.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4196_SD_frame_10.vrt GX_4196_SD_frame_10.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4196_SD_frame_10.cut.vrt GX_4196_SD_frame_10.xyz