#!/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.7821871 56.58984792 -gcp 14118.0 0.0 23.81416936 56.60385183 -gcp 14118.0 14040.0 23.83798242 56.58583942 -gcp 0.0 14040.0 23.80617946 56.5730133 GX4474/GX_4474_SD_frame_86.jpg GX_4474_SD_frame_86.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "600.0 1752.9738743746525\n13800.0 1656.9205113952198\n13752.0 12702.723735408561\n576.0 12486.603668704838" | \ gdaltransform -tps -output_xy GX_4474_SD_frame_86.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4474_SD_frame_86.vrt GX_4474_SD_frame_86.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4474_SD_frame_86.cut.vrt GX_4474_SD_frame_86.xyz