Subscribe to this thread
Home - General / All posts - Spatial Overlap on overlapping areas - help please
Louise James50 post(s)
#20-Jan-23 03:37

I want to assign points to areas, and I was using the spatial overlay feature. However the areas are overlapping and so points may fall into more than one area. When I run the spatial overlay points are assigned to only one area. The relationship is one point may have multiple areas, and one area will have multiple points.

See attached example file I have setup to demonstrate my issue. Any assistance here would be wonderful.

Many thanks in advance

Kind regards

Louise

I am running V8.0.30

Attachments:
Example overlapping area issue.map

oeaulong

521 post(s)
#20-Jan-23 15:33

Try it with spatial query.

SELECT [Areas].[AreaName][Points].[ID]

FROM [Points Grid 1000m] as Points, [WAMEX Areas] as Areas

WHERE  Contains([Areas].[ID],[Points].[ID]);

This should produce the results of AreaName & Point IDs that fall within each of the areas.

Louise James50 post(s)
#20-Jan-23 19:55

Just great! Many thanks for your assistance here. I believe it has done exactly what I was chasing. I will look further into the query syntax to see how I might be able to add additional fields into the output, and alsohow to view the result spatially. Many thanks again

oeaulong

521 post(s)
#21-Jan-23 00:14

it is barebones, though you are welcome. in my opinion, learn a bit about the sql creation process for queries in 8, it will better prepare you for a version 9 transition. There is much and more that you can do that will work well in the UI transform bar, but one never knows when unexpected behavior emerges. often enough, there are multiple paths to solving these sorts of conundrums, might involve some brain twisting. I got the above from testing the example in the "Queries using Two Drawings" section of https://manifold.net/doc/mfd8/selecting_objects_with_queries.htm

Louise James50 post(s)
#23-Jan-23 04:07

Thank you so much for pointing me towards the manifold help notes. Exactly what I was chasing to help me understand the solution. I see the query results are live, and link back to the tables and the map layer - just awesome. The solution is just so powerful, yet so simple.

Thanks again.

Louise James50 post(s)
#24-Jan-23 01:06

Would it be possible to do a similar thing with two overlapping areas, rather than Areas and points. Any comments most welcome. Maybe something like this?? This does not run.

SELECT [Areas].[AreaName], [Areas].[TenID]

FROM [WAMEX Areas] as Area1, [Tenement] as Area2,

WHERE Contains([Areas][AreaName].[ID],[Areas][TenID].[ID]);

Many thanks

Kind regards

Louise

artlembo


3,400 post(s)
#24-Jan-23 01:11

Replace:

WHERE Contains([Areas][AreaName].[ID],[Areas][TenID].[ID]);

With:

WHERE Contains([Area1].[ID],[Area2].ID]);

Louise James50 post(s)
#24-Jan-23 01:31

Many thanks for your prompt assistance here. I seem to have a syntax issue still. Something not quite right. I have added in the second area to the example attached. Apologies I did not originally include a map file for example.

PerhapsI should have also indicated that the areas will overlap and not be totally contained as was the case for the points. Perhaps I need to use a different function than "Contains". Just a thought

Very much appreciate the assistance here

Kind regards

Louise

Attachments:
Example overlapping area issue 2 Query.map

adamw


10,447 post(s)
#25-Jan-23 13:10

Fix three typos (in bold) and then it runs:

SELECT [Area1].[AreaName][Area2].[TenID]

FROM [WAMEX Areas] as Area1, [Tenement] as Area2 -- here

WHERE Contains([Area1].[ID],[Area2].[ID]);

Typo 1: Areas -> Area1. Your FROM section says that there will be two tables, one with an alias of Area1, another with an alias of Area2. None use the alias of Areas.

Typo 2: Areas -> Area2. Same as above.

Typo 3: there was an extra comma where the comment 'here' is.

tjhb
10,094 post(s)
#24-Jan-23 03:58

Would it be possible to do a similar thing with two overlapping areas, rather than Areas and points. Any comments most welcome. Maybe something like this?? This does not run.

I don't think you want Contains(). That finds exactly what it says, an object which completely contains another. It does not detect overlaps except in the case of full containment (or identity).

If you want to detect partial overlaps, you need first to detect touching pairs of areas, then clip each touching to detect a residue.

Art's code also has a typo (a missing left square bracket in the last line).

Louise James50 post(s)
#24-Jan-23 04:19

Excellent. Many thanks for your comments here. Very much appreciated. I will stick to my points / area method for now.

Kind regards

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.