#!/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 4212.0 2211.0 22.337216666666666 57.75 -gcp 25347.0 2184.0 22.837216666666666 57.75 -gcp 25443.0 21855.0 22.837216666666666 57.5 -gcp 4149.0 21867.0 22.337216666666666 57.5 lnb/src1/raw/35101040.jpg 35101040.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "4212.0 2211.0\n12357.0 2223.0149916712935\n13932.0 1686.0\n15054.0 1391.9833425874515\n15936.0 1272.0\n16938.0 1254.0566352026653\n16926.0 2202.0016657412552\n25347.0 2184.0\n25443.0 21855.0\n4149.0 21867.0" | \ gdaltransform -tps -output_xy 35101040.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 35101040.vrt 35101040.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 35101040.cut.vrt 35101040.xyz