#!/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 708.0 705.0 23.5 57.333333333333336 -gcp 5382.0 723.0 24.166666666666668 57.333333333333336 -gcp 5397.0 5061.0 24.166666666666668 57 -gcp 681.0 5049.0 23.5 57 2_izdevums/18_Riga.jpg 18_Riga.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "249.0 237.0\n240.7505270555165 2984.2637423653528\n686.9768095572733 2990.245002776235\n681.0 5052.0\n5401.876317638791 5064.375208217657\n5393.999472944483 2999.2520821765684\n5841.750527055516 2997.747084952804\n5839.492621222769 264.0" | \ gdaltransform -tps -output_xy 18_Riga.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 18_Riga.vrt 18_Riga.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 18_Riga.cut.vrt 18_Riga.xyz