#!/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 23.87212157 56.59486317 -gcp 14418.0 0.0 23.76333117 56.59993089 -gcp 14418.0 14253.0 23.77820671 56.65541858 -gcp 0.0 14253.0 23.87271166 56.65152024 GX3897/GX_3897_SK_frame_55.jpg GX_3897_SK_frame_55.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "600.0 1560.8671484157871\n14088.0 1608.8938299055028\n14112.0 12750.750416898276\n528.0 12575.959977765426" | \ gdaltransform -tps -output_xy GX_3897_SK_frame_55.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_3897_SK_frame_55.vrt GX_3897_SK_frame_55.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_3897_SK_frame_55.cut.vrt GX_3897_SK_frame_55.xyz