Question

Count points in area based on an attribute value

  • 13 November 2019
  • 13 replies
  • 21 views

Badge

Hello,

 

I have a bunch of polygons (grid squares) and points.

Each point has an attribute to qualify its type (1, 2, 3, 4...).

 

 

First I tried to create in each square an attribute with the number of points it contains.

This I achieved using a PointOnAreaOverlayer.

 

Now I want to create on each square X attributes with the number of point by type.

GRID_IDTYPE1_countTYPE2_countTYPE3_count...XXXXXXX0122

 

YYYYYYY1122

 

ZZZZZZZ1284

 

 

The thing is I don't know inadvance which type I'll get. I can have types 1/2/3 one time but then 1/3/4/6.

Two questions I ask myself about this:

  1. How can I ventilate the features by type not knowing in advance the different types (with the testfilter I need to know the types in advance...)
  2. How to get my counts attributes ?

Any help will be welcome :)


13 replies

Userlevel 1
Badge +21

To start with, I would take use the point on Area Overlayer to transfer the Grid_ID to each point. You can then send the points to a statistics calculator grouping by Grid ID and Type. Then you need to pivot the data

Count_points_in_area.fmwt

Badge

To start with, I would take use the point on Area Overlayer to transfer the Grid_ID to each point. You can then send the points to a statistics calculator grouping by Grid ID and Type. Then you need to pivot the data

Count_points_in_area.fmwt

Thanks @ebygomm for your fast answer !

Nevertheless, I can't predict which will be the names of my attributes to expose in the AttributeExposer as the types can vary depending on the inputs (I gave you one extract for the example).

A maybe related question I asked myself already in the past is : is it possible to ventilate the features by type not knowing in advance the different types.

As i would do with a TestFilter if I know the types :

But I don't know how to do this. I expect it would help me but not sure how...

This is a parallel question though...

Userlevel 1
Badge +21

Thanks @ebygomm for your fast answer !

Nevertheless, I can't predict which will be the names of my attributes to expose in the AttributeExposer as the types can vary depending on the inputs (I gave you one extract for the example).

A maybe related question I asked myself already in the past is : is it possible to ventilate the features by type not knowing in advance the different types.

As i would do with a TestFilter if I know the types :

But I don't know how to do this. I expect it would help me but not sure how...

This is a parallel question though...

Ventilate = fanout?

If you're writing something dynamically, it is not necessary to expose the attributes on the canvas, although it is not necessarily straightforward.

If you want to split them within the workspace, for example in a test filter then that is not possible unless you know the attributes in advance.

Badge

Ventilate = fanout?

If you're writing something dynamically, it is not necessary to expose the attributes on the canvas, although it is not necessarily straightforward.

If you want to split them within the workspace, for example in a test filter then that is not possible unless you know the attributes in advance.

yes ventilate = fanout.

Indeed, it can be sufficient to use it only when writing to output. I'll give it a try.

Badge

Ventilate = fanout?

If you're writing something dynamically, it is not necessary to expose the attributes on the canvas, although it is not necessarily straightforward.

If you want to split them within the workspace, for example in a test filter then that is not possible unless you know the attributes in advance.

@ebygomm With fanout I can for example create an Excel file with the name of the ID or a tab in the Excel file with the name of the ID but I can't create X columns with the name of the ID and the count relative to this ID.

I think I'll have to find another way or check with the requestor if he can give me a fixed list of possible values...

Userlevel 1
Badge +21

@ebygomm With fanout I can for example create an Excel file with the name of the ID or a tab in the Excel file with the name of the ID but I can't create X columns with the name of the ID and the count relative to this ID.

I think I'll have to find another way or check with the requestor if he can give me a fixed list of possible values...

It is possible, by creating the schema within the workspace. In this way you can write out attributes without knowing what they are. I normally use python to create a schema when doing this but i think it's possible without as well

Userlevel 1
Badge +21

An example of writing to excel without exposing attributes @p.jeremie

Count_points_in_area_to_excel.fmwt

Count_points_in_area_to_excel_2018.fmwt

Badge

It is possible, by creating the schema within the workspace. In this way you can write out attributes without knowing what they are. I normally use python to create a schema when doing this but i think it's possible without as well

Hum... and how would you do this with or without python @ebygomm ?

I'm not sure to understand what you mean by "creating the schema"...

Badge

Hum... and how would you do this with or without python @ebygomm ?

I'm not sure to understand what you mean by "creating the schema"...

@ebygomm can you tell me what you mean by "creating the schema" ?

Userlevel 1
Badge +21

@ebygomm can you tell me what you mean by "creating the schema" ?

There is an example in the post i created at Nov 13 at 01:40 PM

 

Badge

An example of writing to excel without exposing attributes @p.jeremie

Count_points_in_area_to_excel.fmwt

Count_points_in_area_to_excel_2018.fmwt

@ebygomm Apparently you use a FME version > 2018.1 so I can't open your fmwt without loosing some transformers (and the links).

I tried to recreate the transformers and links but I don't understand how you count and create the points by TYPE in each grid square feature.

- the requestor input port of the featuremerger is linked to what ? GRID ?

- where do you count the points by grid square ?

Maybe you can put printscreens of the transformer settings and workspace ?

Badge

There is an example in the post i created at Nov 13 at 01:40 PM

 

My bad, I didn't saw this answer !

Userlevel 1
Badge +21

@ebygomm Apparently you use a FME version > 2018.1 so I can't open your fmwt without loosing some transformers (and the links).

I tried to recreate the transformers and links but I don't understand how you count and create the points by TYPE in each grid square feature.

- the requestor input port of the featuremerger is linked to what ? GRID ?

- where do you count the points by grid square ?

Maybe you can put printscreens of the transformer settings and workspace ?

I've uploaded a 2018 version above

Reply