Skip to main content
Question

SpatialSorter

  • 11 December 2020
  • 1 reply
  • 41 views

 

 

Hello all,

I am taking the Basic Course in Safe website and I am really enjoying using this fantastic software.

I am doing the exercise called Residential Garbage Collection Zones and I do not understand the SpatialSorter Step (This is the link).

 

The ExpressionEvaluator takes the TotalResident attribute for each feature and divides it by 5 (rounding the result), creating an extra attribute called GroupSize where each value is 109.

The SpatialSorter, group the points in spatial proximity and create an extra attribute called GroupId.

 

What I do not understand is how the 109 value (which is the attribute GrupSize) is used to create the GruoupId. What the calculation the SpatialSorter is doing?

Why if I give a value different than 109 in GrupSize, the SpatialSorter gives me more or less GroupId (5 or 9 for example).

I see as the Spatial sorter is giving the right result, the calculation is absolutely correct but I cannot understand the calculation that SpatialSorter is doing.

 

Thank you

Hi @929marc​. Great question. The SpatialSorter is a custom transformer hosted on the FME Hub. You can view the documentation for it here. It uses a Hilbert Curve to do spatial grouping. The docs report:

"Group Size is an optional parameter (x) that can be set to any integer greater than zero. When set each feature is given a group ID number, where the group size is x features. For example, when set to 100 the data is given an attribute that defines groups of 100 features. Because the data has been spatially sorted it means that each group should occupy its own space, with minimum overlap to other groups."

 

We want five garbage zones, but the transformer is set up to use group size (i.e. number of members in a group), so we have to work backward to figure out how many addresses to include in each group. That's where the 109 value comes from. Then we supply that to the SpatialSorter as Group Size. Then, as I understand it, SpatialSorter does the spatial sorting, then goes down the list and assigns a sequential GroupID to a number of features equal to Group Size. This produces spatially-proximate groups.

 

If you want to really get into the weeds, you can actually right-click the SpatialSorter and click Edit. This opens the custom transformer and you can see exactly how it works! All the way on the right of the canvas is a bookmark named "Create Group IDs". This bookmark is where the GroupID attribute is actually created. You can see it uses a Counter, ModuloCounter, and ExperssionEvaluator to generate the GroupID value.

 

groupidI believe @mark2atsafe​ created the transformer and might be able to clarify if I missed anything.


Reply