Mapinfo 9.5 Problem with contains/intersects returning too little or too much information.

432 views
Skip to first unread message

Nynx

unread,
Jan 21, 2010, 8:51:27 AM1/21/10
to MapInfo-L
Hello All,

Forgive me for my laymans terms but I have been landed with an
embedded Mapinfo 9.5 application which is returning spurious
intersecting data for a plotted polygon. Despite trawling through the
'Net, this forum and the user guides for clues as to how to fix our
problem I'm not really up to speed with all the correct terminology

Our application allows the user to plot a polygon (Usually a spefic
property or plot of land) and then attempts to drill through the
layers retrieving any data from the layers where the plotted polygon
intersects. Pretty standard stuff I'd expect. Where our problem lies
is that in some cases the user may also wish to plot an area inside a
neighbouring property, and if so we would want to include that data
too.

Our problem is that we only want to return all intersecting data that
appears *inside* the plotted polygon and not any neighbouring layers
that are adjacent to the the plotted polygon. The current code uses
'Intersect' which returns too much data (neighbouring properties that
have not being plotted into) and when modified to 'Contains' it only
returns data for any neighbouring polygons where the plotted polygon
covers the centroid of the neighbouring property.

Is there any way of retrieving data that only lies within the plotted
polygon, regardless of whether the centroid is covered or not?

I hope this makes sense but to clarify I have put together an
illustration of our problem:

http://www.mis-lgs.com/downloads/MapinfoRules.jpg

Thank you in advance for any advice on how we can achieve the desired
results.

Peter Horsbøll Møller

unread,
Jan 21, 2010, 11:14:16 AM1/21/10
to mapi...@googlegroups.com
The operator you are looking for might be Contains Entire or Entirely Within.
This will only return the records that are entirely within the other object.
But looking at you picture it seems as if you are aware of this option.
I must admit I'm not really sure what you are trying to do.
 
You could also add a buffer outside or inside the object you are searching with to add some sort of tolerance to the search.
Or you could specify that the size of the overlap should be greater than a certain length/area.

Peter Horsbøll Møller
Pitney Bowes Business Insight - MapInfo

2010/1/21 Nynx <uot...@hotmail.com>
--
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To post to this group, send email to
mapi...@googlegroups.com.
To unsubscribe from this group, send email to
mapinfo-l+...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/mapinfo-l?hl=en.




andrewgmurphy

unread,
Jan 21, 2010, 11:18:10 AM1/21/10
to MapInfo-L

Hi,

As far as I'm aware Intersects is the query you would want.


I don't know about the rest of the group but I would have used the
intersects query here. I'm a bit suprised you are getting record 3
back from the intersects. It would suggest the boundary between 2 and
3 isn't flush and it could be possible that a stray vertex somewhere
does cross the boundary between 2 and 3

If there is one vertex not snapped it could be possible that the
boundaries do intersect eachother.

There is a good page on the MapInfo Professional Helpfile showing the
difference between each of the Spatial Queries.

http://reference.mapinfo.com/software/mapinfo_pro/english/9.0/MI_UG.pdf
Page 332

This guide is for MapInfo 9.0 but it all still applies to MapInfo 9.5.

Intersects does not worry about Centroid, whereas the Within query
uses the centroid of a polygon.

Good luck.

Andrew

Gentreau

unread,
Jan 21, 2010, 11:33:20 AM1/21/10
to mapi...@googlegroups.com

Looking at your image, I wonder if MapBasic is actually behaving correctly.
The correct function should be Contains Part and your example shows that it
returns objects 1,2,3.
Ths may be correct if the borders of object 3 and 2 are identical.
In that case the blue polygon does indeed contain part of 3 even if it's
only the border-line.

Maybe you need to reduce the search polygon very slighly, by creating a
buffer within the search polygon with a buffer distance of minus a few
inches or centimetres.

Then run the query on the buffer object, not the original object.

Gentreau.

Eric Blasenheim

unread,
Jan 21, 2010, 5:43:29 PM1/21/10
to MapInfo-L
Another mechanism you can use is to use the Overlap() function plus
area.

So to filter out neighboring regions that only have a common boundary
and that the intersects operator returns true for you can use

Select * from table where area(overlap(obj, testobj), "sq in") > 0

Overlap will return empty objects for regions with just a common
boundary. Note that this will be slower than intersects because we are
creating the actual objects of intersection for each comparison. But
that may not be an issue.

Eric Blasenheim
PBBI (MapInfo)

> results.- Hide quoted text -
>
> - Show quoted text -

Nynx

unread,
Jan 25, 2010, 8:36:43 AM1/25/10
to MapInfo-L
Thank you for your replies. It looks like maybe a negative buffer or
maybe the overlap idea might be what I need to try.

Cheers!

Nynx

unread,
Feb 9, 2010, 11:36:03 AM2/9/10
to MapInfo-L
Hello Again,

I finally managed to get the system working as required using a
negative buffer as suggested. The code I used applies a -5cm negative
buffer on any polygons plotted in the original LCPlotlayer into a new
table called 'Buffer'. I simply run the intersects operator on the new
table and the results then only return anything inside the originally
plotted polygon and not any neighbouring polygons.

Cheers all.

Although specific to my solution here's the code in case it helps
anyone in the future:

Create Table "buffer" (MISRef Char(50)) file "C:\Documents and Settings
\lee\My Documents\buffer.TAB" TYPE NATIVE Charset "WindowsLatin1"
Create Map For buffer CoordSys Earth Projection 8, 79, "m", -2, 49,
0.9996012717, 400000, -100000 Bounds (-7845061.1011, -15524202.1641)
(8645061.1011, 4470074.53373)
Add Map Layer buffer
Set Map Layer 1 Editable On
Create Object As Buffer From LCPlotLayer Width -5 Units "cm" Type
Cartesian Resolution 12 Into Table buffer Group by Rowid Data
MISRef=MISRef

Robert Dunn

unread,
Sep 26, 2014, 3:52:02 AM9/26/14
to mapi...@googlegroups.com
Morning All,

I know this was a while ago, but I'd be interested to know if there is a tool that can be downloaded that solved this problem. I'm having the same issue. I want to create a buffer around a site boundary and find every layer that intersects this boundary. I'm alittle confused by the code you posted being pretty new to mapbasic. 

Regards. 

Rob. 
Reply all
Reply to author
Forward
0 new messages