2

I have two MapInfo Tab files as Point feature. both the layer have the same unique ID. what I was trying to do is to connect both point using the same ID as a Line feature. so the end result will be "Line Feature" created by two separate point tab file. please help me to resolve this issue using MapBasic. currently I am using MapInfo 15.2.

enter image description here

Above image states two separate point feature that I was tying to connect which have same id field.

1

Let's assume your tables are called TABLE1 and TABLE2 and that your ID column is called ID in both tables.

'First you need to create a new empty table for the result
Create Table TABLE3 Using TABLE1 File "C:\Table3.tab"

'This tables should also be made mappable
Create Map For TABLE3 Using TABLE1

'Let's specify the coordinatesystem to use
Set CoordSys Table TABLE3

'And now we are using SQL to extract the necessary data from the tables
Select TABLE1.ID
   , CreateLine(CentroidX(TABLE1.OBJ), CentroidY(TABLE1.OBJ)
        , CentroidX(TABLE2.OBJ), CentroidY(TABLE2.OBJ)) "THELINE"
    From TABLE1, TABLE2
    Where TABLE1.ID = TABLE2.ID
    Into __TO__BE__INSERTED NoSelect

'And now let's insert the result into the new table
Insert Into TABLE3
    (ID, OBJ)
    Select ID, THELINE From __TO__BE__INSERTED 

Notice that I'm create a derived spatial object - the line - and giving the "column" an alias in the query: THELINE.

I can then refer to this derived spatial column when I insert the result into my new table.

0

As far as I know, there isn't a built-in way to connect points from two separate tables in MapInfo without writing a MapBasic script.

However, if you could combine the points into a single table, you could load the MapCAD toolbar and run either Create Line from Table or Create Polyline from Table. Because of the stellar documentation in MapInfo, these tools are actually called "Create Lines from Database" and "Create Polylines from Database" in the help.

Create Lines from Database

Create line objects (two nodes) from database columns. The table containing line information needs at least four numeric columns with coordinate values and has to be mappable. Datasets with coordinate values=0 will be ignored.

Create Polylines from Database

Create polylines from database columns. Both the whole table and a single selection can be edited.

  • Thank you so much for your prompt response and for your suggestion. could you please also tell me the MapBasic script to create this line. thanking you kindly for your kind help – user68956 Mar 9 '16 at 22:50
  • Sorry, I don't know MapBasic. – Fezter Mar 9 '16 at 22:51
  • okay. no problem. thank you again for your help. Kind Regards – user68956 Mar 9 '16 at 22:52
  • is there anyone who can help me with Map Basic to create lines from two separate point tab files? – user68956 Mar 9 '16 at 23:22
  • Rather than ask a question in the comments, I suggest editing your original question to indicate that you specifically want a MapBasic solution to this problem. – Fezter Mar 10 '16 at 0:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.