24from __future__
import print_function
27import osgeo.gdalconst
as gdalc
31 print(
"Usage: window.py <raster> <x> <y> <xsize> <ysize>")
32 print(
"\traster - GDAL supported dataset")
33 print(
"\tx - column - 1..N where N is raster X dimension")
34 print(
"\ty - row - 1..N where N is raster Y dimension")
35 print(
"\txsize - x-dimension of requested window (xsize <= xsize of raster - x)")
36 print(
"\tysize - y-dimension of requested window (ysize <= ysize of raster - y)")
40 if gt[0] == 0.0
and gt[1] == 1.0
and gt[3] == 0.0
and gt[5] == 1.0:
47 xgeo = gt[0] + gt[1] * x + gt[2] * y
48 ygeo = gt[3] + gt[4] * x + gt[5] * y
55inxoff = int(sys.argv[2])
56inyoff = int(sys.argv[3])
57inxsize = int(sys.argv[4])
58inysize = int(sys.argv[5])
60print(
"File: %s" % infile)
62print(
"- upper-left: %d x %d" % (inxoff, inyoff))
63print(
"- dimensions: %d x %d" % (inxsize, inysize))
65ds = gdal.Open(infile, gdalc.GA_ReadOnly);
67 sys.exit(
'Cannot open input file: ' +
str(infile))
71print(
"=== RASTER ===")
72print(
"- dimensions: %d x %d" % (xsize, ysize))
74if inxsize > xsize
or inysize > ysize
or inxoff > xsize
or inyoff > ysize:
75 print(
"Invalid size of input window")
78gt = ds.GetGeoTransform()
84 print(
"- pixel size:", res)
85 print(
"- upper left:", ulp)
86 print(
"- rotation :", rot)
88 print(
"No georeferencing is available")
91print(
"=== WINDOW ===")
calculate_corner(gt, x, y)