#!/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 24.38671947 57.55393652 -gcp 21600.0 0.0 24.3324423 57.56015462 -gcp 21600.0 21852.0 24.34449493 57.58967825 -gcp 0.0 21852.0 24.39873576 57.58341298 GX4195/GX_4195_SD_frame_8.jpg GX_4195_SD_frame_8.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "864.0 3336.0\n936.0 19440.0\n21456.0 19752.0\n21240.0 3264.0" | \ gdaltransform -tps -output_xy GX_4195_SD_frame_8.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4195_SD_frame_8.vrt GX_4195_SD_frame_8.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4195_SD_frame_8.cut.vrt GX_4195_SD_frame_8.xyz