#!/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 0.0 0.0 27.789919393877934 57.18639454850007 -gcp 16200.0 0.0 28.169308977609827 57.18600494945549 -gcp 16200.0 16824.0 28.16781703726587 56.9716416964259 -gcp 0.0 16824.0 27.790811447518173 56.9716717374704 275-Jaunlatgale_1922.jpg 275-Jaunlatgale_1922.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e \"1563.0 1536.0\n1548.1875 8068.312708217658\n1539.0 14599.876041088282\n15153.75 14591.62312604109\n15121.5 8053.500208217658\n15098.25 1514.9983342587452\" | \ gdaltransform -tps -output_xy 275-Jaunlatgale_1922.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}'))))" \ 275-Jaunlatgale_1922.vrt 275-Jaunlatgale_1922.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 275-Jaunlatgale_1922.cut.vrt 275-Jaunlatgale_1922.xyz