Geotransforms

May-June, 2018, Mauro Alberti

Last run: 2019-06-16

1. Examples


In [1]:
from pygsf.spatial.rasters.geotransform import *

In [2]:
gt1 = GeoTransform(1500, 3000, 10, 10)

In [3]:
gt1


Out[3]:
GeoTransform(topLeftX: 1500.00, topLeftY: 3000.00, pixWidth: 10.00, pixHeight: -10.00, rotRow: 0.00, rotColumn: 0.00)

Forward and backward transformation examples


In [4]:
ijPixToxyGeogr(gt1, 0, 0)


Out[4]:
(1500.0, 3000.0)

In [5]:
xyGeogrToijPix(gt1, 1500, 3000)


Out[5]:
(0.0, 0.0)

In [6]:
ijPixToxyGeogr(gt1, 1, 1)


Out[6]:
(1510.0, 2990.0)

In [7]:
xyGeogrToijPix(gt1, 1510, 2990)


Out[7]:
(1.0, 1.0)

In [8]:
ijPixToxyGeogr(gt1, 10, 10)


Out[8]:
(1600.0, 2900.0)

In [9]:
xyGeogrToijPix(gt1, 1600, 3100)


Out[9]:
(-10.0, 10.0)

calculating the X, Y geographic coordinate arrays


In [10]:
X, Y = gtToxyCellCenters(
    gt=gt1,
    num_rows=10,
    num_cols=5)

In [11]:
print(X)


[[1505. 1515. 1525. 1535. 1545.]
 [1505. 1515. 1525. 1535. 1545.]
 [1505. 1515. 1525. 1535. 1545.]
 [1505. 1515. 1525. 1535. 1545.]
 [1505. 1515. 1525. 1535. 1545.]
 [1505. 1515. 1525. 1535. 1545.]
 [1505. 1515. 1525. 1535. 1545.]
 [1505. 1515. 1525. 1535. 1545.]
 [1505. 1515. 1525. 1535. 1545.]
 [1505. 1515. 1525. 1535. 1545.]]

In [12]:
print(Y)


[[2995. 2995. 2995. 2995. 2995.]
 [2985. 2985. 2985. 2985. 2985.]
 [2975. 2975. 2975. 2975. 2975.]
 [2965. 2965. 2965. 2965. 2965.]
 [2955. 2955. 2955. 2955. 2955.]
 [2945. 2945. 2945. 2945. 2945.]
 [2935. 2935. 2935. 2935. 2935.]
 [2925. 2925. 2925. 2925. 2925.]
 [2915. 2915. 2915. 2915. 2915.]
 [2905. 2905. 2905. 2905. 2905.]]