Skip to content

FME2011 Use Case: Coordinate Swapping

Mark Ireland
June 2, 20114 min
Here's a short and sweet post about a new transformer in FME2011: the CoordinateSwapper

Hi FME’ers,
Here’s a short and sweet post about a new transformer in FME2011: the CoordinateSwapper

The CoordinateSwapper transformer does as you’d imagine and swaps coordinates from one axis to another; for example X becomes Y and Y becomes X. I can see three potential uses for such a transformer.

Lat/Long Swapping
You’re probably aware of the controversy about coordinate order in spatial data; should it be lat-long (Y/X) or long-lat (X/Y)? I think it’s generally accepted that long-lat (X/Y) is the preferred option, but you might still find some datasets where this is reversed.

This is the reason why this transformer was created. It was intended as a way to allow users to quickly and easily switch their lat-long data to long-lat (or vice versa if they preferred).

Very simply you just place the transformer and specify an X Y swap….

…which will have this effect:


The nice thing about this transformer is that it also includes the ability to swap the X or Y coordinate with the Z value. That way you can create cross-sections of data very easily.

Check out this workspace (click to enlarge):

The source data is a transit line that I would like a cross section of. The data prep consists of providing Z values by draping the transit line over a DEM. The only transformer of real interest there is the Scaler, where I am scaling the Z values to give a better display of elevation change in the output.

There are two CoordinateSwapper transformers. Firstly I swap X and Y, because the line runs North to South and I wish to see it run from Left to Right on the output.

Then I swap Y and Z to turn it into a cross-section. The output looks like this:

Not visually stunning, but not bad for a couple of minutes work. It clearly shows how the line increases in elevation – at a very much exaggerated scale – as it heads north out of the city. It wouldn’t be too much work to plot stations on there as well (I just don’t have that data).

I suppose if I had rider numbers I could attach them as a Z value (instead of elevation) and see where ridership spikes occur.

For another example, check out the CoordinateSwapper page on fmepedia, where I swap coordinates on a 3d model of the Gavle Goat to get a view in different perspectives:

No reason why you couldn’t do the same with a more realistic CAD or BIM 3D model!

Data QA
But what might be the most useful function of this transformer is as a tool for data QA.

For example, it’s very hard to tell from a 2D view if a feature is missing Z values or has a wildly incorrect Z value:

But with the CoordinateSwapper transformer, you can swap in the Z values for X or Y, and get a much clearer view of where there are problems:

As you can see, it’s a very powerful tool for locating spikes in Z values.

I hope this short post will be of use – and don’t forget to check out the What’s Great page on fmepedia for a full list of the new transformers in FME2011.


Safe product icons
Reach out and get started with FME today

Real change is just a platform away.