Select where multiple objects are within a region

1,444 views
Skip to first unread message

hayleigh

unread,
Jan 20, 2011, 7:02:42 PM1/20/11
to MapInfo-L
Hi All,

I have two tables of data, one is an address layer of point data and
the other is polygons of property bounadries.

I want to select the polygons that have more than one address within
them, I am sure there must be a function to do this, but so far my SQL
selects havent worked.

Any help much appreciated,
Thanks,
Hayleigh

Owen

unread,
Jan 21, 2011, 5:44:41 AM1/21/11
to mapi...@googlegroups.com
Hello,
 
Theres probably a fancy SQL way to do this, but you could add a column to your addresses called count, and a column to your boundaries called number of points.
 
Then use Table> Update Column to add a 1 to all address records in the count field. Next, use update column to  update your boundaries (#points field) getting the value from the address points table, joined where objects from the address ponts are within the boundries. Finally, choose to calculate the sum of 'count'.
 
Hope that makes sense.
 
Owen 

keith drew

unread,
Jan 21, 2011, 5:58:51 AM1/21/11
to mapi...@googlegroups.com
You could do a two stage sql which looks like this:
 
Select Columns: BoundaryFile.ID, Count(*) <insert more columns here if required>
From tables: Boundary, Address
Where condition: Boundary.obj contains Address.obj
Group by columns: Boundary.id
 
Then from the resulting query
 
Select Columns: *
From tables: Query1
Where condition: col2>1
 
This should give you the boundaries where there are more than one address within.
 
Keith


--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

e.j.h.polle

unread,
Jan 21, 2011, 6:01:03 AM1/21/11
to MapInfo-L
Hi Hayleigh,


Suppose your properties boundary table is called:
'Property_Boundaries' (with a column 'PropertyID' identifying the
properties) and you adress table is called 'Adresses'. The following
query should give you a list with the number of adresses by property,
with the properties with the highest number of adresses appearing at
the top of the list:

Select Property_Bounadries.PropertyID, Count(*) from
Property_Bounadries, Addresses where Property_Bounadries.Obj Contains
Addresses.Obj group by Property_Bounadries.PropertyID order by 2 desc
into Number_OF_Adresses_By_Property

After replacing the table names and the column name with the relevant
values, you can execute this query via the MapBasic window, or you can
create the query yourself by using the Query > SQL Select dialog.

HTH,


Egge-Jan
Reply all
Reply to author
Forward
0 new messages