Skip to main content
I'd like to use a Reprojector to reproject a feature, perform a calculation on it and then reproject back to the original coordinate system. I don't know the CS of my source data until runtime.

 

 

Using the Reprojector it's easy to do the first part, simply select "Read from feature" as the source coordinate system. However, how do I get back to the original source CS in the 2nd reprojection?

 

 

I tried saving out the CS prior to the original reprojection using a CoordinateSystemExtractor but the 2nd reprojector won't accept it's destination coordinate system from the value of an attribute...

 

 

I'm using FME 2012 SP3.

 

 

thanks,

 

Nic
Hi Nic,

 

 

Way not just use the features in the original CS further on in the ws? you can add your calculations results to it by merging.

 

Hope this helps.

Hi @erik_jan or someone else, I am stuck reading a gml file with an OGR namespace in it. FME generates the reader feature type correctly, however, when I run the workspace (FME 2017, even with only an inspector attached to the feature type), it seems that whatever I do, FME throws an error: 

XML Parser error: 'Error in input dataset:'C:\xxxxx.gml' line:15 column:10 message:invalid element name 'ogr:''
The XML Module halted on error, see the logfile for details.

The logfile gives me only this:

A <schemaLocation> in the uri-map is overriding the namespace 'http://www.w3.org/1999/xlink' xsd location from 'http://schemas.opengis.net/gml/3.1.0/xlink/xlinks.xsd' to 'xlink.xsd'
A <schemaLocation> in the uri-map is overriding the namespace 'http://www.w3.org/1999/xlink' xsd location from 'http://schemas.opengis.net/gml/3.1.0/xlink/xlinks.xsd' to 'xlink.xsd'
<GML_1 Reader> - Using the current GML 3.2.1 reader to read v3.1.1 and v2.1.2 documents.
<GML_1 Reader> - Map Embedded Object as: 'ATTRIBUTES'
<GML_1 Reader> - Map Predefined Properties: 'NO'
<GML_1 Reader> - Map All Substitutable Properties: 'YES'
<GML_1 Reader> - Map Complex Properties as: 'NESTED_ATTRIBUTES'
<GML_1 Reader> - Add XML Namespace Prefix to: 'UNSET'
<GML_1 Reader> - Limit Number of Lists in Nested Attributes: 'UNSET'
<GML_1 Reader> - Map as objects 'gml:FeatureCollection'
<GML_1 Reader> - Skip as objects 'wfs:FeatureCollection'
Using XSD semantics configuration file 'file:///E:/Prog/apps/FME2017/xml/gml_v3.2/gml_config.xml'.
Pre-processing xfMap 'C:\Temp\XFMAP_AUTOGEN158887498862_7944.xml' with macro stylesheet 'E:\Prog\apps\FME2017\xfmap\xfmap_macro.xslt' into 'C:\Temp\GML_XFMAP_CACHE\CACHED_AUTOGEN_158887498872_7944.xfmap'
FME Configuration: Using FME Reprojection Engine
The XML Reader is using xfMap 'C:\Temp\GML_XFMAP_CACHE\CACHED_AUTOGEN_158887498872_7944.xfmap'

I could use a textfile reader or a gml reader in xfPath mode, however I also have an xsd which I presume should work properly (and is not too complex), so I rather would use that schema. Has it something to do with the namespace reference:

xmlns:ogr="http://ogr.maptools.org/"

 not being there? I am really a dummy in the world of GML. Also tried it in FME 2019.2 yet gives me the same error. Hope you/someone can help. 

 


Hi Nic,

 

 

I agree with Itay, you might be better off discarding the geometries after the first reprojection and just merging back the calculated result into the original geometries.

 

 

This is because, depending on a lot of factors, reprojecting back and forth may
  • take a lot of time as some reprojection algorithms are quite complex
  • introduce subtle inaccuracies in your geometries as not all reprojections are "loss-less" in accuracy
It is up to you to decide if this is acceptable to you in your case, but you ought to be having them in mind before you implement such a solution.

 

 

David
Thanks Itay and David for your answers. I guess I'll stick with the FeatureMerger, was just hoping for a more efficient solution in terms of processing time.
Hi Nic,

 

 

If you are doing a lot of merging, you should consider making use of the Inline querier or in some cases the joiner, which can reduce the processing time.

 

take in account that for every feature merger that you have indexes of the features involved are created.

 

 

Hope this helps.

 

 

 


As a point of reference when reprojecting, Safe now seem to be suggesting that the CSMapReprojector should now be considered as the default reprojection transformer. A excerpt from a recent correspondence with Safe is as follows:

 

 

Starting in FME 2013 we recommend using the CSMAPReprojector for all coordinate system transformations  More information can be found here: http://fmepedia.safe.com/articles/FAQ/CS-Map-upgrade-in-FME-2013
Itay, the InlineQuerier and Joiner are not suitable for my requirements but thanks for the suggestions.

 

 

SpatialDave, thanks for the info on the CSMapReprojector.
I'll throw out a couple of suggestions that may or may not help...

 

 

1) Can you carry out the calculation in the original CS and then reproject the result? eg With the ReprojectLengthCalculator

 

 

2) You could store the geometry (GeometryExtractor), do the reprojection/calculation, then restore the original geometry with a GeometryReplacer. It *might* be quicker - but encoding/storing geometry does come with an overhead

 

 

3) The Reprojector in 2013 does let you select coordinate system from an attribute, if you're able to upgrade.

 

 

Regards

 

 

Mark
Hi Mark,

 

I'd looked at the ReprojectLengthCalculator when investigating solutions but it has the same problem as a straight reproject in that you need to know your CS in advance in order to provide it to the transformer.

 

 

GeometryExtractor/Replacer is an interesting solution that I wasn't aware of, thanks for that.

 

 

I'm going to stick with the FeatureMerger solution because it doesn't seem to be too slow after all.

 

 

Good to hear that 2013 will allow the CS to be specified from an attribute value. Continuous improvement from Safe - it's the little things that make the difference!

 

Nic
I tried out the GeometryExtractor/Replacer solution and, based on some very rudimentary testing, it appears to be slightly faster for me than the FeatureMerger approach and an added benefit is that it cleans up the look of the workspace with less connecting lines.  :)

 

 

I like this approach and, for me, it could theoretically be significantly faster. I'm using FeatureMerger's quite a lot throughout the workspace simply to merge features back to their original geometries after an operation has altered them. Using the GeometryExtractor I will be able to store the geom once at the start of the workspace and then restore it as needed.

 

 

Nice!

Reply