[GIS] Selecting lines occupying identical positions in MapInfo or QGIS

linemapinfoqgisquery

I have two shapefiles from a client, one is their entire network (complete with unique IDs) and another a selection I need. However the selection file does not have unique IDs but the entire one does. How would I be able to select the lines that appear in both files from the entire network shapefile?

Thanks,
Alan

Best Answer

For Mapinfo you should try this methods.

method (Intersects)

Copy this SQL code in some text editor. Replace table names (table1 and table2) with your tables (where first table is a entire network with IDs and second one is a partial) and save it with extension .QRY.

Fields {*}
Tables {table1, table2}
Where {table1.Obj Intersects table2.Obj}
Group {}
Order {}
Into {Selection}

Then, in MapInfo go to menu QUERY/SQL Select... (or press ALT+Q and again press Q) Now you are in SQL Select editor. Click on LOAD TEMPLATE and load QRY file.

Check again with Verify and click OK. You should get all lines from table1 that intersects table2

method (creating a Buffer)

Select all objects from Table2. Then create a buffer around it > Objects/Buffer…

  • enter some small value in “Value” (0.2meters)
  • choose “One buffer for each object”

In next dialog (Data Aggregation) set 'Aggregation Method' all to “Value” then OK.

You have now a small buffer around each object in table2.

Now create like in previous example a QRY file and run it:

Fields {*}
Tables {table1, table2}
Where {table1.Obj Entirely Within table2.Obj}
Group {}
Order {}
Into {selection}

You should get all lines from table1 that intersects table2