#!/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.14101667 56.91943333 -gcp 21600.0 0.0 24.09103333 56.91425 -gcp 21600.0 21729.0 24.08021667 56.94213333 -gcp 0.0 21729.0 24.13223333 56.94765 GX2200/GX_2200_SD_frame_76.jpg GX_2200_SD_frame_76.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1056.0 3287.8132295719843\n21240.0 2952.0266814897163\n21264.0 19176.160088938297\n1128.0 19439.85325180656" | \ gdaltransform -tps -output_xy GX_2200_SD_frame_76.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2200_SD_frame_76.vrt GX_2200_SD_frame_76.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2200_SD_frame_76.cut.vrt GX_2200_SD_frame_76.xyz