#!/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.30231571 57.10789768 -gcp 21627.0 0.0 24.33398724 57.00966431 -gcp 21627.0 21573.0 24.16023374 56.99578739 -gcp 0.0 21573.0 24.12885189 57.0862008 GX2206/GX_2206_SK_frame_69.jpg GX_2206_SK_frame_69.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1152.0 3167.251253481895\n21072.0 3023.8395543175484\n21072.0 18911.679108635097\n960.0 18912.588300835654" | \ gdaltransform -tps -output_xy GX_2206_SK_frame_69.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2206_SK_frame_69.vrt GX_2206_SK_frame_69.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2206_SK_frame_69.cut.vrt GX_2206_SK_frame_69.xyz