Skip to main content

Hi there,

I've been struggling for a while now to generate stats in the way I want to for a few specific Shape files I have. I've tried toying around with the statistic calculator for a while, but not getting exactly what I need.

So, as a representation of my shapefile's contents, here's an example of what I have:

TypeColorSizeShapeMetersARedSMLTRI11ARedSMLRND15ARedMEDRND10BRedMEDRND20BRedLRGRND13BBlueLRGRND16CBlueSMLSQR14CBlueSMLSQR19CGreenMEDTRI17

 

And here's what I'd like to have as an output (aiming for a plain excel sheet):ItemValueMetersCountTypeA363TypeB493TypeC503ColorRed695ColorBlue493ColorGreen171SizeSML494SizeMED473SizeLRG292ShapeTRI282ShapeRND745ShapeSQR332

Basically I just want the counts and total measurements (I already have the METERS attribute in my source) for each unique value for specified attributes (like Color, or Value etc..)

Realistically speaking I'd probably do a fanout on "Item" to make the sheet less clunky, but that I already know how to do.

Please feel free to ask if there's anything else I need to explain in more detail.

Thanks in advance,

Hi

I think I found the solution with a couple of StatisticsCalculators:


Hi jeroenstiers,

Thanks, this really works brilliantly and gives me exactly what I wanted, except one issue:

 

My meters attribute does not pass through the Stats calculator. It seems like that transformer removes the attribute, so when I add it to the output writer, it shows a red arrow, and running the workspace, meters remain blank.

Any idea what may be the cause of this?


Probably because the result is meters and not Meters, you need to map meters to Meters for your output.


Hi @robbie_botha, the features output via the Summary port of the StatisticsCalculator don't have the "Meters" attribute, but they should have the sum of the value of "Meters" for each group. I guess that the sum attribute has been renamed to "meters" with the AttributeManager in @jeroenstiers' example.

This is another approach. FYI.


Ahh thanks @takashi, I missed the Meters becoming _sum part, it works perfectly now.

Thanks to you and @jeroenstiers, really appreciate the swift help.

Cheer,


Hi @robbie_botha, the features output via the Summary port of the StatisticsCalculator don't have the "Meters" attribute, but they should have the sum of the value of "Meters" for each group. I guess that the sum attribute has been renamed to "meters" with the AttributeManager in @jeroenstiers' example.

This is another approach. FYI.

0684Q00000ArKkyQAF.png

For what it's worth, an InlineQuerier with this SQL statement could work as well.

 

select
    'Type'      as Item,
    Type        as Value,
    sum(Meters) as Meters,
    count(*)    as Count
    from source group by Type
union all select 'Color', Color, sum(Meters), count(*)
    from source group by Color
union all select 'Size',  Size,  sum(Meters), count(*)
    from source group by Size
union all select 'Shape', Shape, sum(Meters), count(*)
    from source group by Shape
0684Q00000ArMYrQAN.png

 


Reply