#!/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 1332.0 1083.0 24 58.666666666666664 -gcp 21864.0 1224.0 26 58.666666666666664 -gcp 21975.0 14205.0 26 58 -gcp 1065.0 14073.0 24 58 lnb/24635489.jpg 24635489.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1332.0 1083.0\n11607.0 1221.0366870483601\n21864.0 1224.0\n21975.0 14205.0\n11514.0 14206.537520844915\n1065.0 14073.0" | \ gdaltransform -tps -output_xy 24635489.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 24635489.vrt 24635489.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 24635489.cut.vrt 24635489.xyz