Skip to content

Commit 5647333

Browse files
committed
Created Datum transformation tutorial
1 parent 2c5db99 commit 5647333

File tree

5 files changed

+174
-5
lines changed

5 files changed

+174
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
This is a package of tools for manipulating geospatial datasets using Python and tested in Python 3.6.4.
66

7-
### Tutorials
7+
### Documentation
88

9-
See [here](https://github.com/GeoscienceAustralia/GeodePy/tree/master/docs/tutorials) for worked examples of common GeodePy functions and routines.
9+
See [here](https://geodepy.readthedocs.io/) for documentation around downloading and using GeodePy.
1010

1111
### Dependencies
1212

docs/features/constants.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ These classes can be used to create objects that store the relevant parameters f
1818
.. autoclass:: geodepy.constants.Projection
1919
:members:
2020

21+
.. _transclass:
22+
2123
.. autoclass:: geodepy.constants.Transformation
2224
:members:
2325

@@ -62,6 +64,8 @@ For :class:`~geodepy.constants.Projection`:
6264
| isg | Projection | Integrated Survey Grid (NSW, AGD66) |
6365
+-----------------------------+---------------------+-------------------------------------------------------------+
6466

67+
.. _features/constants/transform:
68+
6569
Transformation
6670
^^^^^^^^^^^^^^
6771

docs/tutorials/edmcorrectiontut.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Within GeodePy, EDM corrections can be completed. To complete an EDM correction
1616

1717
Using these we can calculate the first velocity correction and reduce to a horizontal distance.
1818

19-
First the variables need to be defined. Below is the values for a Lecia Viva
19+
First the variables need to be defined. Below is the values for a Lecia Viva.
2020

2121
.. code:: python
2222

docs/tutorials/timedeptranstut.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
.. _tutorials/timetrans:
22

33
Time Dependant Transformations
4-
==============================
4+
==============================
5+
6+
In this tutorial we will discuss time dependant transformations where the reference epoch needs to be changed.
7+
To see transformations between static datums view the :ref:`datum transformation <tutorials/transform>` tutorial.

docs/tutorials/transformtut.rst

Lines changed: 163 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,166 @@
11
.. _tutorials/transform:
22

33
Datum Transformation
4-
=====================
4+
=====================
5+
6+
GeodePy has the ability to tranform between datums. Here we will discuss how to
7+
change between datums without changing the reference epoch while in the
8+
:ref:`time dependant <tutorials/timetrans>` tutorial we will discuss changing epochs.
9+
10+
Common Example
11+
--------------
12+
13+
The most common example for datum transformation is converting from MGA94 to MGA2020.
14+
This is handled by a function in the transformation module that converts the input to
15+
grid input to caresian coordinate (xyz), and then runs a 7 paramter helmert transformation
16+
using the GDA94_to_gda2020 transformation constant. This process will be explored more in
17+
the :ref:`latter <tutorials/transformfunc>` part of this tutorial but first lets use this function.
18+
19+
Begin by importing GeodePy:
20+
21+
.. code:: python
22+
23+
import geodepy.transform
24+
25+
Next, define some coordinate values in MGA94:
26+
27+
.. code:: python
28+
29+
zone_94 = 55
30+
east_94 = 696053.3373
31+
north_94 = 6086610.1338
32+
33+
Now, transform this coordinate to MGA2020:
34+
35+
.. code:: python
36+
37+
(zone_20, east_20, north_20, _, _) = geodepy.transform.transform_mga94_to_mga2020(
38+
zone_94,
39+
east_94,
40+
north_94
41+
)
42+
43+
Finally, print the transformed coordinate:
44+
45+
.. code:: python
46+
47+
print(zone_20, east_20, north_20)
48+
49+
This will output the zone, easting and northing of the coordinate in MGA2020.
50+
51+
.. code::
52+
53+
>> 55 696053.872 6086611.549
54+
55+
In this transformation you can see that a function from the transformation module was used.
56+
57+
.. _tutorials/transformfunc:
58+
59+
Constructing a new Transformation Function
60+
------------------------------------------
61+
62+
Here we will explore how to complete a transformation between datums without a dedicated function.
63+
We will then create a new function for this new transformation. Here we are going to transform between agd84 to gda2020
64+
65+
First import GeodePy.
66+
67+
.. code:: python
68+
69+
import geodepy.transform
70+
import geodepy.constants
71+
import geodepy.angles
72+
73+
Now we need some starting coordinates
74+
75+
.. code:: python
76+
77+
lat = geodepy.angles.DMSAngle(-23,33,25.21)
78+
long = geodepy.angles.DMSAngle(133,49,13.87)
79+
height = 427.863
80+
81+
print(f"The AGD84 position is {lat}, {long}, {height}"
82+
83+
>>The AGD84 position is -23 33 25.21, 133 49 13.87, 427.863
84+
85+
All transformations in GeodePy need to be completed with corrdinates in cartesian (xyz) form. Lets transform to xyz.
86+
87+
.. code:: python
88+
89+
x, y, z = geodepy.transform.llh2xyz(lat, long, height)
90+
print(x, y, z)
91+
92+
>>-4050634.051819 4220935.13646 -2533555.369303
93+
94+
Now the transformation parameters need to be entered. Within Geodepy there are many transformaton parameters already
95+
entered within the constants module. A table of these can be seen :ref:`here <features/constants/transform>`. If the
96+
transformation needed isn't currently in Geodepy, new transofmrations can be added using the :ref:`transformation class <transclass>`.
97+
Here the agd66_to_gda94 transformation will be used.
98+
99+
.. code:: python
100+
101+
print(geodepy.constants.agd84_to_gda94)
102+
103+
>>Transformation: From 'AGD84' to 'GDA94'
104+
>>Reference Epoch: 0
105+
>>tx: -117.763m + 0.0m/yr
106+
>>ty: -51.51m + 0.0m/yr
107+
>>tz: 139.061m + 0.0m/yr
108+
>>sc: -0.191ppm + 0.0ppm/yr
109+
>>rx: -0.292" + 0.0"/yr
110+
>>ry: -0.443" + 0.0"/yr
111+
>>rz: -0.277" + 0.0"/yr
112+
113+
Now this will be used to complete a 7 paramter helmert transformation.
114+
115+
.. code:: python
116+
117+
x_94, y_94, z_94, _ = geodepy.transform.conform7(x, y, z, geodepy.constants.agd84_to_gda94)
118+
print(x_94, y_94, z_94)
119+
120+
>>-4050762.150962 4220880.96717 -2533401.14935
121+
122+
.. tip::
123+
The "_" in the conform7 variables is for a vcv matrix. If you dont input a vcv matrix
124+
then the resulting variable will be None. However as the variable needs to be assigned
125+
for the function to work using "_" meets to requirement but doesn't store the variable
126+
in a meaningful way.
127+
128+
Now we need to transform from GDA94 to GDA2020 using the same method but with the gda94_to_gda2020
129+
transformation class.
130+
131+
.. code:: python
132+
133+
x_20, y_20, z_20, _ = geodepy.transform.conform7(x_94, y_94, z_94, geodepy.constants.gda94_to_gda2020)
134+
135+
print(x_20, y_20, z_20)
136+
137+
>>-4050763.124034 4220880.75310 -2533399.713463
138+
139+
Now the cartesian coordinates can be converted back to geographic coordinates (lat, long)
140+
141+
.. code:: python
142+
143+
lat_20, long_20, height_20 = geodepy.transform.xyz2llh(x_20, y_20, z_20)
144+
145+
print(f"The GDA2020 position is {geodepy.angles.dec2dms(lat_20)}, {geodepy.angles.dec2dms(long_20)}, {height_20}")
146+
147+
>>The GDA2020 position is -23 33 19.921108332, 133 49 18.481110119, 411.61055134
148+
149+
All of this can now be combined into one function.
150+
151+
.. code:: python
152+
153+
def transform_agd84_to_gda2020(lat, long, height):
154+
155+
x, y, z = geodepy.transform.llh2xyz(lat, long, height)
156+
x_94, y_94, z_94, _ = geodepy.transform.conform7(x, y, z, geodepy.constants.agd84_to_gda94)
157+
x_20, y_20, z_20, _ = geodepy.transform.conform7(x_94, y_94, z_94, geodepy.constants.gda94_to_gda2020)
158+
159+
return geodepy.transform.xyz2llh(x_20, y_20, z_20)
160+
161+
lat_new, long_new, height_new = transform_agd84_to_gda2020(lat, long, height)
162+
163+
print(f"The GDA2020 position is {geodepy.angles.dec2dms(lat_new)}, {geodepy.angles.dec2dms(long_new)}, {height_new}")
164+
165+
>>The GDA2020 position is -23 33 19.921108332, 133 49 18.481110119, 411.61055134
166+

0 commit comments

Comments
 (0)