Skip to main content
Question

How to use feature count (or a value derived from feature count) as a parameter.

  • April 14, 2021
  • 1 reply
  • 573 views

Hi all,

 

I’m working on an FME script and I’ve hit a wall I can’t seem to get over.

 

Basically, I’m using a custom transformer (PointClusterer) to cluster a bunch of points by proximity. The number of clusters I want is however many it takes to have groups of 300 plus remainder. So if I have 1500 points, I have five groups, 1501 points, I have six, 1499 points, I have five etc.

 

The problem is that the PointClusterer transformer wants the number of clusters, not the cluster divider, and I want this field to be filled in dynamically based on the characteristics of the data I'm loading in.

 

pic1Theoretically, this shouldn’t be a problem. There are a bunch of different ways to get FME to calculate the number of clusters I want based on the total feature count I load in. Here’s an example of a really basic way I cooked up. I take the total count of features, divide that number by 300, round down, then add 1 and write that number to a field as an integer.

pic2 Unfortunately, when I connect this feature to the PointClusterer transformer and tell it to use my ClusterValue field, I get this error:

pic3I suspect this is because by selecting that attribute for that parameter I'm feeding in each row of the feature instead of just a single value.

 

I've run into situations in the past where I've needed to use just a single value from a feature as a parameter (the min, the max, sum, whatever, but I've never been able to figure out how and I've always had to come up with a clumsy work around. My question is: is there a way to take the value I calculated by doing operations on the total feature count, and use it to fill in a transformer parameter that is just looking for a single value?

 

Thank you for your time.

1 reply

caracadrian
Contributor
Forum|alt.badge.img+23
  • Contributor
  • April 15, 2021

You can always get a Total Count attribute via StatisticsCalculator, divide the Total Count by how many points you want in your clusters and set that attribute as Number of Clusters in PointClusterer


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