# Transformation pipelines¶

In these exercises we will learn how to use Transformation Pipelines. Transformation Pipelines is a powerful construct in PROJ that allow users to combine several operations into one "super operation". Pipelines are used extensively internally in PROJ when a user asks for a transformation between two CRS's (for example when using cs2cs). However, users can also write their own custom pipelines for specific purposes.

Before moving on to the exercises below, familiarize yourself with the pipeline operation in the documentation. Pay special attention to the rules that govern the use of the pipeline operation.

Download the gie file for the exercise: `pipelines.gie`.

## 1. Geodetic -> Helmert -> Geodetic¶

The signature use case for transformation pipelines is the Helmert transformation of geodetic coordinates.

As we have seen in the previous exercises, fundamentally, the Helmert operation works on cartesian coordinates. So when the input coordinates are geodetic, we must convert them to the cartesian space before applying the Helmert transformation.

Similarly, we must convert the transformed cartesian coordinates back to geodetic space to be able to compare the coordinates before and after transformation.

With that in mind, now create a transformation pipeline that take geodetic (longitude/latitude) coordinates, applies a Helmert transform, and returns geodetic coordinates (in a different datum).

To keep it simple we will use the GRS80 ellipsoid for both input and output datum, and a basic 3 parameter transformation, with translations 100,200,300, and using the position vector convention.

Hint

Remember that in a pipeline step, the inverse of an operation is selected by adding `+inv` to the parameter list of the operation.

```operation   <your answer here>
tolerance   1 m

accept      12.0           53.0          75.0
expect      12.00260406    53.00062190  398.48468
```

## 2. Sequential grid shifts¶

Create a transformation that applies both a horizontal and a vertical grid adjustment. Use the `de_adv_BETA2007.tif` and the `us_nga_egm96_15.tif` grids.

1. Does it matter which grid is applied first?

2. If yes, which goes first? Why?

Hint

```operation   <your answer here>
tolerance   1 cm

accept      12.0            53.0        75.0
expect      11.99846399     52.99852627 34.541488647
```

## 3. ED50/UTM32 -> ETRS89/UTM33¶

A transformation from one coordinate reference system to another. A very common use case of transformation pipelines.

In this exercise we have UTM Zone 32 coordinates related to the ED50 datum, which we want to transform to UTM Zone 33 related to ETRS89.

The transformation goes

1. Back-projection

2. Geodetic to cartesian conversion

3. Helmert transformation

4. Cartesian to geodetic conversion

5. Re-projection

which is a very common recipe for transformations between projected coordinate systems.

Hint

Find the relevant Helmert parameters by running:

```projinfo -k operation EPSG:1626 -o WKT2_2019
```

Hint

If you can't remember which ellipsoids is used by ED50 and ETRS89 you can look them up with:

```projinfo <datum>
```

Hint

Relevant documentation:

```operation   <your answer here>
tolerance   1 cm

accept      687080.63      6210278.55   0
expect      312871.16      6210214.58   34.08
```

## 4. A pipeline from the Real World¶

The transformation between the German DHDN and ETRS89 is a transformation pipeline consisting of eight steps. Lookup the transformation with projinfo:

```projinfo -k operation EPSG:1776
```

and copy and paste the pipeline definition as your answer below. Try to decipher the pipeline and answer the following questions:

1. What is the input coordinate type and units?

2. What is the output coordinate type and units?

3. What is the purpose of the +proj=push and +proj=pop steps?

Hint

A pipeline definition can span several lines in the gie format. Use this to your advantage and put each step on it's own separate line for easier reading

Hint

You can use projinfo to get more knowledge about a particular CRS:

```projinfo <CRS name or code>
```

Hint

Look at Push coordinate value to pipeline stack and Pop coordinate value to pipeline stack to find out how to set up the transformation

```operation   <your answer here>
tolerance   3 m

accept      12.0           53.0          75.0
expect      12.0032        52.9953       75.0000
```