[GIS] Finding all polygons overlapping polygons from another layer using MapInfo

intersectionmapinfooverlapping-features

I have two polygon layers. One is All_India_Locality layer which has attributes:{Locality_ID,Locality_Name} and the other is All_India_Pincode layer which has attributes:{Pincode,City}

enter image description here

I want to find all the pincodes that are overlapping the localities. So my output should be a table which has attributes:{Locality_ID,Locality_Name,Pincode}.

enter image description here

There's one catch theat pincodes which are just sharing boundaries with the localities should not be selected. (Therefore intersect query won't work)

Example: For the highlighted locality "8781", only Pincode "574105" should be displayed in Pincode column as it overlaps the locality "8781". Pincodes "576107" and "574118" should not be displayed as they are sharing the boundary.
If localities are overlapped by multiple pincodes, then multiple records of same locality should be present.

I am using mapinfo. One workaround I found for this query is that I split the localities layer with pincodes layer and then updated the Pincode column with pincode values from pincode layer using query "Pincode.obj contains Localities.obj"

Is there any other way?

Best Answer

I'm assuming that a locality object is only covered by one pincode object, right?

You can do this in three steps:

  1. Add a column to hold the pincode to the locality table
  2. Use SQL Select to join the two tables
  3. Update the locality layer using the join query result

Let's try:

First you need to add a column for the pincode to the Locality table

Next we are joining the two tables

Select All_India_Locality.Locality_ID
   , All_India_Locality.Locality_Name, All_India_Locality.Pincode "L_Pincode"
   , All_India_Pincode.Pincode "P_Pincode", All_India_Pincode.City
From All_India_Locality, All_India_Pincode
Where All_India_Locality.OBJ Intersects All_India_Pincode.obj
And Area(Overlap(All_India_Locality.OBJ, All_India_Pincode.obj), "sq m") > 100
Into Locality_Join_Pincode

Notice that the I have included multiple columns in the result. That's so that you better can see if it looks correct. Also note that I have used a tolerance of 100 sq m to determine whether a locality object is covered by a pincode object. This should remove those that only share a common boundary.

Now you can update the pincode on the Locality layer with the pincode from the Pincode layer using the query result

Update Locality_Join_Pincode Set L_Pincode = P_Pincode
Related Question