#!/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 1827.0 705.0 22 56 -gcp 13617.0 699.0 24 56 -gcp 13830.0 11181.0 24 55 -gcp 1752.0 11199.0 22 55 opt_lt/txu-oclc-6519747-nn34-3.jpg txu-oclc-6519747-nn34-3.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1827.0 705.0\n7722.0 747.775430794886\n13617.0 699.0\n13830.0 11181.0\n7779.75 11235.775430794885\n1752.0 11199.0" | \ gdaltransform -tps -output_xy txu-oclc-6519747-nn34-3.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ txu-oclc-6519747-nn34-3.vrt txu-oclc-6519747-nn34-3.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES txu-oclc-6519747-nn34-3.cut.vrt txu-oclc-6519747-nn34-3.xyz