#!/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 615.0 912.5013881177124 24.510449513090943 57.81646088711499 -gcp 9381.0 912.7479178234314 24.57295241108404 57.816460887110374 -gcp 9385.5 11902.69156024431 24.57295241108391 57.774794629190325 -gcp 609.75 11907.941976679624 24.510449513090823 57.77479462919495 k_001_ktL2-0-132_0058.jpg k_001_ktL2-0-132_0058.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "615.0 912.5013881177124\n9381.0 912.7479178234314\n9385.5 11902.69156024431\n609.75 11907.941976679624" | \ gdaltransform -tps -output_xy k_001_ktL2-0-132_0058.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ k_001_ktL2-0-132_0058.vrt k_001_ktL2-0-132_0058.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES k_001_ktL2-0-132_0058.cut.vrt k_001_ktL2-0-132_0058.xyz