#!/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.076822400093082 56.9965427191192 -gcp 21600.0 0.0 24.102383852005005 56.997809358812574 -gcp 21600.0 21852.0 24.104518890380863 56.98362402765039 -gcp 0.0 21852.0 24.078946709632877 56.98249867211601 GX4799/GX_4799_SD_frame_12.jpg GX_4799_SD_frame_12.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "600.0 2724.0\n624.0 19392.0\n20952.0 19416.0\n21036.0 2664.0" | \ gdaltransform -tps -output_xy GX_4799_SD_frame_12.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4799_SD_frame_12.vrt GX_4799_SD_frame_12.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4799_SD_frame_12.cut.vrt GX_4799_SD_frame_12.xyz