#!/bin/bash
set -e
set -x

# Size is 188000, 152000
input=./dem_eu_30m.tif

# cornwall
# xoff=75200
# yoff=76000

xoff=0
yoff=0
xsize=1000
ysize=1000

#output="out/dem_eu_30m_x${xoff}_y${yoff}_xs${xsize}_ys${ysize}.tif"
output="out/dem_eu_30m_subwindow.tif"

#gdal_translate -srcwin $xoff $yoff $xsize $ysize $input $output


ulx=55
uly=56

lrx=32
lry=28


#gdal_translate -projwin $ulx $uly $lrx $lry $input $output

gdal_translate -srcwin $xoff $yoff $xsize $ysize $input $output

gdalinfo $output

#gdal_translate -ot Byte -of GTiff -scale 0 3795 0 255 $output $output.tmp


#gdal_translate -of PNG $output.tmp $output.png

#rm -fv $output.tmp $output.png.aux.xml $output

