#!/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 672.0 684.0 24.166666666666668 57 -gcp 5391.0 672.0 24.833333333333332 57 -gcp 5436.0 5007.0 24.833333333333332 56.666666666666664 -gcp 678.0 5028.0 24.166666666666668 56.666666666666664 2_izdevums/25_Ogre.jpg 25_Ogre.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "684.0 672.0\n672.0 5391.0\n5007.0 5436.0\n5028.0 678.0" | \ gdaltransform -tps -output_xy 25_Ogre.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 25_Ogre.vrt 25_Ogre.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 25_Ogre.cut.vrt 25_Ogre.xyz