#!/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 25.81000686 56.25198143 -gcp 43200.0 0.0 25.75982809 56.24826798 -gcp 43200.0 42714.0 25.75210869 56.27703039 -gcp 0.0 42714.0 25.80512524 56.2803301 GX1006/GX_1006_SD_frame_151.jpg GX_1006_SD_frame_151.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1920.0 5664.0\n1776.0 38736.0\n42528.0 39408.0\n42624.0 6048.0" | \ gdaltransform -tps -output_xy GX_1006_SD_frame_151.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_1006_SD_frame_151.vrt GX_1006_SD_frame_151.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_1006_SD_frame_151.cut.vrt GX_1006_SD_frame_151.xyz