Question

Counting total geometry parts in a object

  • 26 November 2018
  • 2 replies
  • 23 views

Badge +7

I'm building a flow that needs the total amount of (external) parts in a geometry feature. I need the total amount of parts from a single (thus 1) or multi-part (2+) feature for further statistical analysis. To get this i used the PartCounter that would give me the _part_count which returns the number of parts in the geometry. For multis and aggregates, this is the number of parts, and for paths, this is the number of segments. Otherwise, it is one.

I would expect that, when using this on a single feature (donut). It would return the value 1 but in the attached example, and all other donuts that i tried, it returns the total amount of donuts + total amount of external parts.

 

Would it be possible to get the partcount without the inner boundaries with another transformer without needing to fill the donutsholes with a DonuHoleFilter? or just get the outer boundary part count?

Filling the donuts is quite time and CPU consuming (example for 10k objects but sets with x million could also be processed and this would take several hours extra) :

28.6 seconds. (CPU: 27.3s user, 1.0s system) VS 1 minute 51.8 seconds. (CPU: 63.4s user, 22.6s system)

Problem in short:

Getting value 51 but would like to have value 1 (1 object, not the inner + outer boundaries).


2 replies

Userlevel 1
Badge +12

Hi, 

I am not sure if there is one transformer that does it by itself, but there is capability by fme python:

 

python screenshot and workspace attacheddontcountdonuts.fmw

0684Q00000ArQ4sQAF.png

 

 

numParts(flatten, splitDonuts)       

 

Get the number of parts that make up the geometry of the feature.

 

Parameters:
  • flatten
     (
    bool
    ) - If flatten is 
    True
    , then return the number of           primitive parts drilling down into sub aggregates. If flatten is           
    False
     then it returns the number of high level parts          with some parts potentially being aggregates.
  •  
  • splitDonuts
     (
    bool
    ) - If splitDonuts is 
    True
    , each ring of a donut will           count as a separate part.
Returns: 
int
The number of parts that make up the feature.
Userlevel 2
Badge +17

Possibly you get desired result if you subtract the number of donut holes (HoleCounter) from the resulting value generated by the PartCounter.

Reply