You can select the records where the coordinates are blank/zero, make the layer editable, and then use the Convert to Polyline option to convert the simple lines into polylines.
In this way, the objects will be identical in your table. Now run the update statement again
Alternatively, you can modify the statement to convert all the objects to polylines using the ConvertToPline()
function before extracting the coordinates:
Set CoordSys Table MSEC
Update MSEC
Set Start_Easting = ObjectNodeX(ConvertToPline(OBJ), 1, 1),
Start_Northing = ObjectNodeY(ConvertToPline(OBJ), 1, 1),
End_Easting = ObjectNodeX(ConvertToPline(OBJ), 1, ObjectInfo(ConvertToPline(OBJ), OBJ_INFO_NPNTS)),
End_Northing = ObjectNodeY(ConvertToPline(OBJ), 1, ObjectInfo(ConvertToPline(OBJ), OBJ_INFO_NPNTS))
In this way, the objects in the table aren't changed. We only convert them to polylines just before extracting the coordinates.
------------------------------
Peter Horsbøll Møller
Principal Presales Consultant | Distinguished Engineer
Precisely | Trust in Data
------------------------------
Original Message:
Sent: 01-10-2025 05:14
From: Robert Hodgson
Subject: Start and End Coordinates of a Polyine
Hi Peter,
Thank you vey much that worked for the majority of the objects in my layer.
However, it didn't work for some of the objects in the layer and just returned blanks. I looked into this and think it may be due to some of the objects in the layer being lines rather than polylines.
Do you know how I could amend the above script to work with lines?
All of the polylines and lines are single segments, with varying numbers of nodes. (images attached)
Thanks again,
Rob
------------------------------
Robert Hodgson
Knowledge Community Shared Account
Original Message:
Sent: 01-10-2025 04:36
From: Peter Møller
Subject: Start and End Coordinates of a Polyine
Hi Rob
You can try this:
Set CoordSys Table MSEC
Update MSEC
Set Start_Easting = ObjectNodeX(OBJ, 1, 1),
Start_Northing = ObjectNodeY(OBJ, 1, 1),
End_Easting = ObjectNodeX(OBJ, 1, ObjectInfo(OBJ,OBJ_INFO_NPNTS)),
End_Northing = ObjectNodeY(OBJ, 1, ObjectInfo(OBJ,OBJ_INFO_NPNTS))
The first statement sets MapInfo Pro to use the same projection as the table.
The functions ObjectNodeX()
and ObjectNodeY()
can extract coordinates from the individual nodes in the polyline/polygon. I'm assuming your polylines all just have a single segment. The function ObjectInfo()
can retrieve specific details about spatial objects. Here I use it to give me the number of nodes in the polyline.
The Start columns will get updated with the coordinates from the first node in the polygons, and the End columns will get the coordinates from the last node of the first segment assuming you only have one segment on each polyline.
You can run this from the MapBasic window or the SQL Window.
------------------------------
Peter Horsbøll Møller
Principal Presales Consultant | Distinguished Engineer
Precisely | Trust in Data
Original Message:
Sent: 01-09-2025 11:26
From: Robert Hodgson
Subject: Start and End Coordinates of a Polyine
Hello,
I have a polyline layer called MSEC and I want to extract the start and end coordinates of the polylines into my table, I have created four columns 'Start_Easting', 'Start_Northing' and End_Easting, End_Northing.
Is there a simple SQL script which i can run to output the coordinates for the start and end points?
Many thanks,
Rob
------------------------------
Robert Hodgson
Knowledge Community Shared Account
------------------------------