#!/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 1254.0 1203.0 22 58 -gcp 22140.0 1245.0 24 58 -gcp 22341.0 14607.0 24 57.333333333333336 -gcp 1023.0 14535.0 22 57.333333333333336 lnb/24635486.jpg 24635486.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1254.0 1203.0\n11991.0 1317.0516953863257\n22140.0 1245.0\n22341.0 14607.0\n11667.0 14661.050027793219\n1023.0 14535.0" | \ gdaltransform -tps -output_xy 24635486.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 24635486.vrt 24635486.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 24635486.cut.vrt 24635486.xyz