Question

Spatialrelator is dropping attributes, how do I fix that?

  • 14 February 2017
  • 8 replies
  • 11 views

I have a model that uses SpatialRelator to join two datasets for me to do further analysis on. I noticed that I was getting fewer results than I should be getting and after researching it a bit, I've noticed that SpatialRelator is taking an input in that every feature has an attribute for in a certain field. As soon as it comes out of SpatialRelator it loses about half of the attributes of the join. (In this case, 140 out of a total of 295 had attributes, the rest were dropped.)

Is anybody else noticing that this transformer is dropping attributes? Any ideas on how to fix this?

Thanks for your time!


8 replies

Userlevel 2
Badge +17
To help us understand the situation correctly, can you clarify these questions?

 

  • Which dataset features have the original 295 attributes, Requestor or Supplier (or both)?
  • Where do the preserved 140 attributes come from, Requestor or Supplier?
  • What version FME are you using?
Badge +7

Hi @wouldworking

I am guessing that a lot of the attribute have the same name and are therefore only kept once. If this is the case you can use two BulkAttributeRenamers and rename all attributes with a prefix '(e.g. 'requestor_' and 'supplier'). Doing so will make sure that there is no attribute with the same name and therefore will no be overwritten.

Badge +16

Hi @wouldworking,

You can avoid that by setting the merge attribute settings to prefix the supplier.

Next tot that a list is generated in which all attributes are found.

Hope this helps

Badge +7

Hi @wouldworking,

You can avoid that by setting the merge attribute settings to prefix the supplier.

Next tot that a list is generated in which all attributes are found.

Hope this helps

Indeed. And just for clarification. This list is not visible in the table view in FME Inspector. You have to select a feature and look at its content in the window 'Feature Information'

 

 

Userlevel 2
Badge +17

Hi @wouldworking,

You can avoid that by setting the merge attribute settings to prefix the supplier.

Next tot that a list is generated in which all attributes are found.

Hope this helps

The Merge Attributes checkbox has been introduced in FME 2016.1 and it is unchecked by default. With the default setting, the attributes of a supplier feature will not be merged to requestor features even if the supplier was spatially related to the requestors.

 

The default behavior is different from the previous version, and also the attribute names from Supplier are exposed on the GUI even if the checkbox is unchecked. This could become a trap.

 

I therefore supposed that it has caused the observation "As soon as it comes out of SpatialRelator it loses about half of the attributes of the join", but it's not sure unless the questions I posted were clarified.An enhancement has been done in FME 2017.0 RC, and the attributes from Supplier will not be exposed when the Merge Attributes checkbox is not checked (PR#72383). FYI.

 

 

To help us understand the situation correctly, can you clarify these questions?

 

  • Which dataset features have the original 295 attributes, Requestor or Supplier (or both)?
  • Where do the preserved 140 attributes come from, Requestor or Supplier?
  • What version FME are you using?
Sure thing!

 

 

I'm using two datasets. Let's call them "Parcels" and "SecondDivision". I'm using the spatialrelator to check which Parcels features are within the SecondDivision features. I get 295 going out from this dataset. 140 of them have the attributes from the Parcels and the SecondDivision layers, just as I'd expect. But the others are dropping all of the attributes from the SecondDivision layer. That borks testers I have later on in the model. It's as though my requester is getting about half of the data, but not the other half...and I don't really see why.

 

 

I'm using 2016.1.1.0 (20160722 - Build 16609 - WIN64)

 

 

Hi @wouldworking,

You can avoid that by setting the merge attribute settings to prefix the supplier.

Next tot that a list is generated in which all attributes are found.

Hope this helps

This looks like it would solve my problems, but my SpatialRelator Parameters window doesn't look anything like yours. I'm using 2016.1...but I suspect there is some sort of version difference. When I figure it out I'll give this a try. Thank you for your help!

 

 

Userlevel 2
Badge +17

ah, I was wrong. I supposed the 295 and 140 indicate the number of attributes, but those seem to be the number of features actually.

Since you need to check which Parcels features are WITHIN the SecondDivision features, you will have to send the Parcels features to the Requestor port, send the SecondDivision features to the Supplier port, and set Within to the Tests to Perform parameter. Also check the "Merge Attributes" checkbox in FME 2016.1+.

Then, all the Percels features will be output via the Output port, but only the features which were WITHIN a SecondDivision feature will have attributes merged from the SecondDivision feature.

In addition, if the requirement is to only check if each Parcels feature is within a SecondDivision feature, you can also use the SpatialFilter transformer. Send the SecondDivision features to the Filter port; send the Parcels features to the Candidate port; set Within to the Tests to Perform parameter. Then, Parcels features which are within any SecondDivision feature will be output via the Passed port, and other Parcels features will be output via the Failed port.

Reply