#!/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 8676.0 7885.279043913286 21.574058532714847 57.40083229642462 -gcp 46812.0 5575.707615341857 25.4058837890625 57.535504245337215 -gcp 57168.0 35086.26737076153 26.49516105651856 55.88589956412389 -gcp 2703.0 34438.23068371318 21.065425872802738 55.91744736765412 316133.jpg 316133.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "0.0 0.0\n67521.0 0.0\n67521.0 40128.0\n0.0 40128.0" | \ gdaltransform -tps -output_xy 316133.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 316133.vrt 316133.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 316133.cut.vrt 316133.xyz