Skip to main content

Pretty sure someone has this resolved. But I just could not find a clean solution to a seemingly basic request...

Before we do an overlay operation of Layer A and Layer B, we need to first test if their CSs are the same. If they are not, Layer A needs to be reprojected to the CS of Layer B.

CoordinateSystemExtractor is used to extract CS as "Attribute" from the two respective layers. But that was how far we could go:

A - How can we compare the CS when the two CS Attributes are in two different datasets?

B - How can we set the "Destination CS" parameter in the Reprojector transformer of Layer A to point to the CS Attribute from Layer B?

Thanks!

I'll have a think about the best way, but I just wanted to mention that the Reprojector will only reproject where necessary, so if you know one coordinate system then you could just reproject to that.

For example, you set up a Reprojector to reproject to coordinate system X

  • If Layer A=X and Layer B=Y, then layer B gets reprojected to match A.
  • If Layer A=Y and Layer B=X, then layer A gets reprojected to match B.
  • If Layer A=X and Layer B=X, then no reprojection takes place because they match already.
  • If Layer A=Y and Layer B=Y (or anything else), then both layers gets reprojected to X and match.

That way you avoid having to worry about determining what coordinate systems they are, you are just making sure there is a match.

But I'll think about the other scenario. First thought is a FeatureMerger will copy that info over.


Two thoughts:

1) I am familiar with Python, but maybe this could be done with a python caller with the following specs: Layer A and Layer B as the input, with Layer A "reprojected" if necessary to Layer B's CS if necessary.

2) This issue can be solved if there is the concept of the "session-based variable" (attributes are dataset specific and is row based) that can be dynamically set by user AND can be referenced just like parameters. This way, we can set the two vars, CS_A and CS_B and we can set the destination CS in the Reprojector transformer as CS_B for example.

bo


I would try the following (assuming dataset A is read first):

Use the CoordinateSystemExtractor to get the attribute containing the coordinate system of A.

Use a VariableSetter to store the coordinate system of A in a variable.

After reading B use the VaraiableRetriever to add the A coordinate system as attribute on B.

Use the Reprojector to reproject B to coordinate system of A (using the attribute as destination). You might have to hold the data until the variable is set (FeatureHolder).

Then both datasets have the same (A) coordinate system.


@erik_jan, I followed your approach and had this working! The attached shows the workflow.

If FME allowed a variable to be accessed similarly to a User Parameter, we would avoid time and bits wasted in retrieving the variable and assigning to an attribute.

Appreciate any comment on this. Thank you!

selection-229.png


@erik_jan, I followed your approach and had this working! The attached shows the workflow.

If FME allowed a variable to be accessed similarly to a User Parameter, we would avoid time and bits wasted in retrieving the variable and assigning to an attribute.

Appreciate any comment on this. Thank you!

selection-229.png

I should have embedded the workflow instead of attaching.


@erik_jan, I followed your approach and had this working! The attached shows the workflow.

If FME allowed a variable to be accessed similarly to a User Parameter, we would avoid time and bits wasted in retrieving the variable and assigning to an attribute.

Appreciate any comment on this. Thank you!

selection-229.png

It would be nice if the Reprojector could take a variable. I agree. I will add this as an idea to the knowledge board.


@erik_jan, I followed your approach and had this working! The attached shows the workflow.

If FME allowed a variable to be accessed similarly to a User Parameter, we would avoid time and bits wasted in retrieving the variable and assigning to an attribute.

Appreciate any comment on this. Thank you!

selection-229.png

Thanks for the example, I just wanted to point out that the FeatureHolder is an important part of this process depending on where you extract the coordinate system. My workbench was running the retriever before the extractor so I needed the featureholder as well.

Reply