Question

Point on Area Overlayer and count points by attribute


Badge

Hi,

I simply need to take two TAB files - one point file containing several attribute fields, and one polygon - in the same projection, and overlay them and then summarise the number of points by attribute in each polygon. The output needs to be the polygon TAB file with a couple of fields of counts.

I have made some progress with the point on polygon overlayer. ie - it runs without generating an error, and the points or the polygons can be mapped in an inspector window.

Other posts suggest generating a list, which i have done, but doesn't seem to produce a list that i can see.

I've tried SQL executor (because I already have SQL code that will run in Mapbasic)

Tried Statistics Calculator.

Tried other things but can't remember what they are.

This is a pretty simple operation to complete in a GIS, but I don't want to have to do the repetitive part, because we have multiple polygons to deal with and repeated data in the future.

Any ideas?

Thanks,

Sean


26 replies

Badge +2

Hi,

I may not be clear on your requirement...

"summarise the number of points by attribute in each polygon" this can be attained by considering _overlaps attribute (Overlap Count Attribute) from PointOnAreaOverlayer.

Or does this mean that few attributes does not values and few have values?

Userlevel 5
Badge +25

Could you post a sample of your input and desired output? I think that'll make it a lot more clear.

Badge +10

I think what you looking for is the option 'Generate List On Output Area' that can be found at the bottom in the 'Attribute Accumulation' part. However you must appoint the attributes that should be a part of that list.

Badge

I think your question should say "does this mean that some attributes do not have values and some have values". If this is what you are asking me, then no my issue is not that there are missing attribute values.

I recall having tried to use the Overlap Count Attribute but I don't know how to get anything useful from it. I gather that this terminology means a point overlaps with a polygon?

Essentially what I am trying to do is boundary tag points and then sum the counts of these points by attribute against each polygon.

Badge

Thank you, this is a good tip. I have had some promising results by following a tutorial that includes generate list.

I will post some data, I just need to edit it first.

Badge

points-and-polygons.zipAttached is a zip file containing the input files, process and final result.

Inputs-

 

Points.TAB

 

Polygons.TAB

Process-

 

The following SQL creates a count of those points with Indicator 1 = "1", the result being a sum of the number of points by polygon - result is PolycountsI1.TAB

SELECT Polygons.Name, Count(*)

 

FROM Polygons, Points

 

WHERE Polygons.Obj Contains Points.Obj AND Points.Indicator1="1"

 

GROUP BY Polygons.Name

Then the SQL code is used to count those points with Indicator 1 = "2" - result is PolycountsI2.TAB

PolycountsI1.TAB and PolycountsI2.TAB do not have geometry, they are attributes only.

Final outputs:

 

PolycountsI1.TAB and PolycountsI2.TAB are then joined to the original Polygons table - the final result is a table with geometry - PolygonsI1_I2.TAB

Thanks again.

Badge +2

Hi @sladlow,

Based on the output required, I have prepared the workbench and attached to this thread. I have connected to the inspector, if it meets, change the writer as required...

Hope this helps

tab-overlap-extract.fmw

Badge +10

points-and-polygons.zipAttached is a zip file containing the input files, process and final result.

Inputs-

 

Points.TAB

 

Polygons.TAB

Process-

 

The following SQL creates a count of those points with Indicator 1 = "1", the result being a sum of the number of points by polygon - result is PolycountsI1.TAB

SELECT Polygons.Name, Count(*)

 

FROM Polygons, Points

 

WHERE Polygons.Obj Contains Points.Obj AND Points.Indicator1="1"

 

GROUP BY Polygons.Name

Then the SQL code is used to count those points with Indicator 1 = "2" - result is PolycountsI2.TAB

PolycountsI1.TAB and PolycountsI2.TAB do not have geometry, they are attributes only.

Final outputs:

 

PolycountsI1.TAB and PolycountsI2.TAB are then joined to the original Polygons table - the final result is a table with geometry - PolygonsI1_I2.TAB

Thanks again.

@sladlow This is the way I should do it in FME.

 

And the resulting table

 

Badge

@lars_de_vries

Hi Lars, thanks so much for this, it really helps. I doubt i would have been able to work this out alone.

Would you mind clarifying a few things for me? Can you please tell me the parameters of the spatial output step at the end, and also how you set the Attribute Value to 2 Possible Values in the Attribute Manager transformer?

Thanks,

Sean

Badge

@pratap

Hi Pratap, this is also really helpful, thanks. While i can see the attributes of the polygons summed in the inspector, when I added a writer to the end of the process that saves the file as a TAB file, the resulting file does not display any summed attributes.

Sean

Badge +2

Hi @sladlow,

You have to add the attributes in the writer. I have added the TAB writers along with attributes. I do not have MapInfo to check the result but I have viewed the TAB files in Inspector.

Hope this helps...

tab-overlap-extract-1.fmw

Pratap

Badge +2

Hi,

Just out of curiosity, I have prepared similar to @lars_de_vries approach and attached

tab-overlap-extract-2.fmw

Badge

Hi @pratap, where are the attributes added in the writer? I can't see anything that would indicate the ability to add attributes in the writer.

Badge +2

Hi,

Hope you are looking at tab-overlap-extract-1.fmw and attribute information is provided in writer properties as given below...

Badge

I don't know, this doesn't work either. I re-downloaded your workspace, pointed the process to the original polygons file and manually added the points file again. I created a new writer that points to the relevant output directory, but it can't write because it is looking for E:\\Temp, which of course doesn't exist. I can't see any reference to an E drive in the workspace. ??

Badge +2

Hi,

No need to change the readers/writers but change the file path in published parameters and then run.

Badge

I set the Destination MapInfo folder to the correct drive in Tools-Edit Parameters. Is this what you meant? No file was created, even though the translation was successful.

Badge +2

Thread is too long :)

Can I have your skype ID or email ID for further discussion...

Badge

Sorry about this. When we got FME I was assured that it was easy to use and that the online support and documentation was very comprehensive, which it is. But I probably need to do some kind of course that covers the basics because I can't seem to get it to work. Do you want me to put my email address in this post?

Badge +2

I understood, Don't worry, It is simple...

Yes please... If you have Skype then it is preferable...

You can get my email ID from my profile view

Badge

Hi, what I think is your profile doesn't have an email address listed. My email address is , I don't have access to Skype at work. I could try at home another time.

Userlevel 5
Badge +25

Sorry about this. When we got FME I was assured that it was easy to use and that the online support and documentation was very comprehensive, which it is. But I probably need to do some kind of course that covers the basics because I can't seem to get it to work. Do you want me to put my email address in this post?

With regards to training, I would highly recommend you watch and work along with one of the recorded training courses, or a live online one: https://www.safe.com/training/recorded/

 

That should get you up to speed quickly.

 

 

Badge +10

Hi @sladlow,

sorry for not responding anymore, but I have been sick for a couple of days and haven't had a look at any computer. Thank you @pratap for continuing to answer the questions.

I think it is really important to learn the basics, like @redgeographics already mentioned too you, to understand every step that has been taken. And also to understand the way FME works.

If you still have issues, please let the community know.

Badge +10

And when I look at the thread your question, @sladlow, about how I set the '2 possible values' had not been answered yet. You can do that using Conditional Statements, those are TestFilters within the AttributeCreator and -Manager, and also many other transformers, that allow you to define an output based on different conditions.

Badge

Thanks @redgeographics I will work through these.

Reply