|
1 | 1 | .. _tutorials/coord: |
2 | 2 |
|
3 | 3 | Coordinate Classes and Conversions |
4 | | -============================================= |
| 4 | +============================================= |
| 5 | + |
| 6 | +GeodePy has 3 coordinate classes that can be used to store coordinates and convert between coordinate types. |
| 7 | + |
| 8 | +The three different classes are: |
| 9 | + |
| 10 | +- :ref:`CoordCart - Cartesian Corrdinates <tut/cart>` |
| 11 | +- :ref:`CoordGeo - Geographic Coordinates <tut/geo>` |
| 12 | +- :ref:`CoordTM - Transverse Mercator Coordinates <tut/tm>` |
| 13 | + |
| 14 | +Classes |
| 15 | +-------- |
| 16 | + |
| 17 | +.. _tut/cart: |
| 18 | + |
| 19 | +Cartesian Coordinates |
| 20 | +^^^^^^^^^^^^^^^^^^^^^^ |
| 21 | +Cartesian coordinates represent points in three dimensions (X, Y, Z), typically in an Earth-Centered, Earth-Fixed (ECEF) system. |
| 22 | +In this class an n value can also be added representing seperation between ellipsoid and geiod. |
| 23 | + |
| 24 | +- **Description:** Defines a point by its distance along three perpendicular axes. |
| 25 | +- **Format:** ``(X, Y, Z)`` in meters. |
| 26 | +- **Example:** ``( -4052051.0, 4212831.0, -2545100.0 )`` |
| 27 | + |
| 28 | +To initalise a cartesian coordinate class: |
| 29 | + |
| 30 | +.. code:: python |
| 31 | +
|
| 32 | + coord1 = geodepy.coord.CoordCart(x, y, z, n=None) |
| 33 | +
|
| 34 | +.. _tut/geo: |
| 35 | + |
| 36 | +Geographic Coordinates |
| 37 | +^^^^^^^^^^^^^^^^^^^^^^ |
| 38 | +Geographic coordinates express positions on the Earth's surface using latitude, longitude, and optionally height. |
| 39 | + |
| 40 | +- **Description:** Latitude and longitude define angular position relative to the equator and prime meridian. |
| 41 | +- **Format:** ``(latitude, longitude, height)`` |
| 42 | +- **Example:** ``(-33.8650°, 151.2094°, 58)`` |
| 43 | + |
| 44 | +To initalise a geographic coordinate class: |
| 45 | + |
| 46 | +.. code:: python |
| 47 | +
|
| 48 | + coord1 = geodepy.coord.CoordGeo(lat, long, ell_ht=None) |
| 49 | +
|
| 50 | +.. _tut/tm: |
| 51 | + |
| 52 | +Transverse Mercator Coordinates |
| 53 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 54 | +A projected coordinate system that maps the curved Earth onto a flat plane using the Transverse Mercator projection. |
| 55 | + |
| 56 | +- **Description:** Represents positions as Easting and Northing values in meters. |
| 57 | +- **Format:** ``(Zone, Easting, Northing, Height)`` |
| 58 | +- **Example:** ``(55, 334567.89, 6254321.12, 58.2)`` |
| 59 | + |
| 60 | +To initalise a transverse mercator coordinate class: |
| 61 | + |
| 62 | +.. code:: python |
| 63 | +
|
| 64 | + coord1 = geodepy.coord.CoordTM(zone, east, north, ell_ht=None) |
| 65 | +
|
| 66 | +Converting Between Classes |
| 67 | +-------------------------- |
| 68 | + |
| 69 | +First import GeodePy |
| 70 | + |
| 71 | +.. code:: python |
| 72 | +
|
| 73 | + import geodepy.coord |
| 74 | + import geodepy.geodesy |
| 75 | +
|
| 76 | +We can now create a coordinate obect. For this example we will use a transverse mercator coordinate. |
| 77 | + |
| 78 | +.. code:: python |
| 79 | +
|
| 80 | + coord1 = geodepy.coord.CoordTM(55, 696053.337, 6086610.13) |
| 81 | + print(coord1) |
| 82 | +
|
| 83 | + >>CoordTM: Zone: 55 East: 696053.337 North: 6086610.13 Ell_Ht: None Orth_Ht: None Hemisphere: South |
| 84 | +
|
| 85 | +This object can now be transformed into the other classes using the inbuilt methods. |
| 86 | + |
| 87 | +.. code:: python |
| 88 | +
|
| 89 | + print(coord1.cart()) |
| 90 | + print(coord1.geo()) |
| 91 | +
|
| 92 | + >>CoordCart: X: -4471828.926838844 Y: 2670252.9985762094 Z: -3669113.8962611817 NVal: None |
| 93 | + >>CoordGeo: Lat: -35.3445551951 Lon: 149.15740394128 Ell_Ht: None Orth_Ht: None |
| 94 | +
|
| 95 | +Individual variables from a coordinate class can be used within different functions. |
| 96 | + |
| 97 | +.. code:: python |
| 98 | +
|
| 99 | + coord1Geo = coord1.geo() |
| 100 | + print(geodepy.geodesy.rho(coord1Geo.lat)) # to calculate radius of curvature of ellipsoid |
| 101 | +
|
| 102 | + >>6356788.983764104 |
| 103 | +
|
| 104 | +Using Convert Functions |
| 105 | +----------------------- |
| 106 | + |
| 107 | +Instead of using classes, function can also be used to convert between coordinate types. The two main conversions function are: |
| 108 | + |
| 109 | +- geo2grid - Converts from geographic (lat, long, h) to grid (E, N, u) |
| 110 | +- xyz2llh - Converts from cartesian (x, y, z) to geographic (lat, long, h) |
| 111 | + |
| 112 | +Both of these functions can be reversed to convert the other way. |
| 113 | + |
| 114 | +To convert using function first geodepy needs to be imported |
| 115 | + |
| 116 | +.. code:: python |
| 117 | +
|
| 118 | + import geodepy.geodesy |
| 119 | + import geodepy.convert |
| 120 | +
|
| 121 | +Now either of the functions can be used |
| 122 | + |
| 123 | +.. code:: python |
| 124 | +
|
| 125 | + coordGeo = geodepy.convert.grid2geo(55, 696053.337, 6086610.13) |
| 126 | + print(coordGeo) |
| 127 | +
|
| 128 | + >>(-35.34455523, 149.15740394, 1.0000737, 1.2484390010290551) |
| 129 | +
|
| 130 | + coordllh = geodepy.convert.xyz2llh(-4471828.926838844, 2670252.9985762094, -3669113.8962611817) |
| 131 | + print(coordllh) |
| 132 | +
|
| 133 | + >>(-35.34455523, 149.15740394, 0) |
| 134 | +
|
| 135 | +These function can be used together to convert between grid and cartesian. |
| 136 | + |
| 137 | +.. code:: python |
| 138 | +
|
| 139 | + coordGeo = geodepy.convert.grid2geo(55, 696053.337, 6086610.13) |
| 140 | + coordCart = geodepy.convert.llh2xyz(coordGeo[0],coordGeo[1]) |
| 141 | + print(coordCart) |
| 142 | +
|
| 143 | + >>(-4471828.924896575, 2670252.9973158445, -3669113.8995236363) |
0 commit comments