Skip to main content
Solved

How to display GroupID with SpatialSorter using FME Workbench 2024


sazerty2
Participant
Forum|alt.badge.img+1

Hi,

I am trying to use the SpatialSorter in my workspace to sort data by location and define group size. However, as I’m currently using the FME Workbench 2024 version, the SpatialSorter is quite different and doesn’t provide a new attribute named “GroupID”, it’s also impossible to define a group size in the parameters.

It is quite inconvenient because it’s not possible to use the Aggregator transformer on the GroupID attribute afterwards to group sorted spatial data.

As far as I know, there is no unexposed attribute generated from SpatialSorter in the FME 2024 version. 

To compensate, I used the  NeighborhoodAggregator but I’m not satisfied by the results.

I was wondering if anyone else encountered the same issue and found another solution ?

 

Thank you for reading!

Best answer by kalbert

Hi @sazerty2.

My understanding is, you’re happy with the spatial sorting but you like to have the sorted results in groups of e.g. 5 records in the sorted order as they got released from the SpatialSorter.

I see two ways to accomplish it:

  1. If you are a bit python you will find many different ways to group records in equal group sizes, so that you can apply it with a PythonCaller.
  2. If you’re more FME native the solution is a ModuloCounter after your SpatialSorter with Count maximum value of your group size. You add a normal Counter downstream with an output count attribute “Group”. Then you add an AttributeCreator using the capability looking one record back when calculating a value (see below). Apply the conditional value as below (adjust modulocount = 4 with the max of your group size -1 (4 is from my sample of max group size = 5)

 

 

As a result you got group ids according to your group size. I was a bit lazy hence the first group will be empty, but it’s an easy task to add e.g. group = 1 for the missing first set.

 

View original
Did this help you find an answer to your question?

2 replies

kalbert
Contributor
Forum|alt.badge.img+12
  • Contributor
  • Best Answer
  • April 3, 2025

Hi @sazerty2.

My understanding is, you’re happy with the spatial sorting but you like to have the sorted results in groups of e.g. 5 records in the sorted order as they got released from the SpatialSorter.

I see two ways to accomplish it:

  1. If you are a bit python you will find many different ways to group records in equal group sizes, so that you can apply it with a PythonCaller.
  2. If you’re more FME native the solution is a ModuloCounter after your SpatialSorter with Count maximum value of your group size. You add a normal Counter downstream with an output count attribute “Group”. Then you add an AttributeCreator using the capability looking one record back when calculating a value (see below). Apply the conditional value as below (adjust modulocount = 4 with the max of your group size -1 (4 is from my sample of max group size = 5)

 

 

As a result you got group ids according to your group size. I was a bit lazy hence the first group will be empty, but it’s an easy task to add e.g. group = 1 for the missing first set.

 


sazerty2
Participant
Forum|alt.badge.img+1
  • Author
  • Participant
  • April 4, 2025

Thank you ​@kalbert for the explanation !

I tried the second option and it worked like a charm

 

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings