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:
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.
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.
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:
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.
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.
We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.