Mapinfo Update Column with Start and End Point Coordinates for Line Objects

983 views
Skip to first unread message

hay...@gmail.com

unread,
Oct 6, 2017, 7:13:51 AM10/6/17
to MapInfo-L
Hello

I am looking to update column fill a series of polyline objects with start and end point coordinates in British National Grid format. Is there a way you can do this with Coordinate Extractor Tool - it normally only seems to do the centre point coordinates.

I have also looked at using the objectgeography (obj,1) expression but this only seems to do it in Latitude / Longitude format - is there a way the extract values can then be converted to British National Grid. Or Is there another tool that has been created which would do this in MapInfo?

Thanks

David Haycock
Bath and North East Somerset Council

college.atlas

unread,
Oct 7, 2017, 6:46:07 AM10/7/17
to MapInfo-L
David,
There is a trick you can pull.

About MI Version 7.0 the "Table Update Column" stopped using the table's own projection.

However you can issue a Set Coordsys through the Mapbasic Window and just like in a Mapbasic script all calculations will now be based on the new Coordsys.

The command you want to issue through the Mapbasic window is something like

set CoordSys Earth Projection 8, 79, "m", -2, 49, 0.9996012717, 400000, -100000

Here's the other trick. If you want the coordinates in the table's own projection you can export the Table to MIF\MID. Opening the MIF file and grab the "Coordsys" line. You can omit the "Bounds" and everything after that.

Also when you're dealing with Polylines the update values for the START Long\Lat, E\N are

ObjectNodeX(obj,1,1)
ObjectNodeY(obj,1,1)

Which translates as the X or Y coordinate of the object first section, first node.

This will work when ALL YOUR OBJECTS are polylines. Occasionally you'll get some LINES mixed up in your polylines. To get around that I force all the objects to be polylines by issuing a ConvertToPline(obj) in the update

ObjectNodeX(converttopline(obj),1,1)
ObjectNodeY(converttopline(obj),1,1)

The more complex issue is the end node.

So building on the the updates above, the end node is variable as polylines have varying number of nodes. 

(Here's  tip for any one from Pitney Bowes. FME by Safe Software addresses polyline nodes in forward and REVERSE count. So you can look at  a polyline from start to end as node 1 to node N. FME also allows you to look at a polyline from End to Start as node -1 to node -N. This would make addressing start and end nodes so much easier) 

I digress, so we need to expand the update for the END 

ObjectNodeX(converttopline(obj),1,ObjectInfo(converttopline(obj),20))
ObjectNodeY(converttopline(obj),1,ObjectInfo(converttopline(obj),20))

So this translates as  the X or Y coordinate of the polyline object, first section, last node(eg total number of nodes in polyline--> ObjectInfo(converttopline(obj),20))

Now believe it or not there's yet another level of complexity. Sometimes you have polylines that have more than one section. This is not to confused with segments. It's possible in Mapinfo to have a multisection polyline which is actually a collection of 2 or more polylines.

The process here is to identify if these objects exist in your data

For example the following query

Select * from yourTABLE where Val(Str$(Objectinfo(converttopline(obj),21))) > 1 into MultiSecPols

would find all the multi section polylines. If you run this and you get no records you can stop here.

However if you get some records you can try the following

ObjectNodeX(ConvertToPline(obj),ObjectInfo(ConvertToPline(obj),21),ObjectInfo(ConvertToPline(obj),21+ObjectInfo(ConvertToPline(obj),21)))
ObjectNodeY(ConvertToPline(obj),ObjectInfo(ConvertToPline(obj),21),ObjectInfo(ConvertToPline(obj),21+ObjectInfo(ConvertToPline(obj),21)))

So I'll do my best to translate this. 
This is the X or Y coordinate of the polyline object, "Nth" section, last node of the "Nth" section

Hope I haven't overloaded you. Good luck.

Warren Vick

unread,
Oct 7, 2017, 11:13:51 AM10/7/17
to mapi...@googlegroups.com

There’s a slightly easier method of setting the active coordinate system in Pro to that used by a table. In the MapBasic window, simply issue the command:

 

set coordsys table YourTableName

 

Calls to functions which return coordinates, such as ObjectNodeX(), will now honour this coordinate system. No exporting and digging around a MIF file required!

 

Regards,

Warren Vick

--
--
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

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

college.atlas

unread,
Oct 8, 2017, 1:40:24 AM10/8/17
to MapInfo-L
Did not know that Warren. 

I rarely have tables in the correct projection for the coordinates I need to extract. 

Nice tip.

Andrew

unread,
Oct 8, 2017, 11:49:05 PM10/8/17
to MapInfo-L
Hi David,

Attached is a bit of code i used about 9 years ago to do what you want for water pipes, might be useful for you.

Regards
Andrew
Start_End_Line_Co-ords.mb

Alamgir Dewan

unread,
Oct 9, 2017, 2:12:20 AM10/9/17
to mapi...@googlegroups.com
Hi David
You can simply use this below code in ur Mapbasic
"
Include "Mapbasic.def"
include "icons.def"

declare sub Main
declare sub UpdateStartEnd

Sub Main
set coordsys earth projection 8, 116, "m", 117, 0, 0.9996, 500000, 10000000
Create Buttonpad "UpdateLineXY" As
Pushbutton
Icon 135 File "xtraicons.dll"
Calling UpdateStartEnd
HelpMsg "Calculate start XY and end XY coordinates"

End Sub

Sub UpdateStartEnd

set coordsys earth projection 8, 116, "m", 117, 0, 0.9996, 500000, 10000000 [Please change this line with your coord system details]
Update "Name of Tab file" set Start_E = ObjectGeography(obj,OBJ_GEO_LINEBEGX)
Update "Name of Tab file" set Start_N = ObjectGeography(obj,OBJ_GEO_LINEBEGY)
Update "Name of Tab file" set End_E = ObjectGeography(obj,OBJ_GEO_LINEENDX)
Update "Name of Tab file" set End_N = ObjectGeography(obj,OBJ_GEO_LINEENDY)

End Sub
"
Hope this will be worth for your use.

Cheers
Alamgir



On Fri, Oct 6, 2017 at 7:13 PM, <hay...@gmail.com> wrote:
Hello

I am looking to update column fill a series of polyline objects with start and end point coordinates in British National Grid format. Is there a way you can do this with Coordinate Extractor Tool - it normally only seems to do the centre point coordinates.

I have also looked at using the objectgeography (obj,1) expression but this only seems to do it in Latitude / Longitude format - is there a way the extract values can then be converted to British National Grid. Or Is there another tool that has been created which would do this in MapInfo?

Thanks

David Haycock
Bath and North East Somerset Council

--
--
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

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Assets GIS Officer

City of Wanneroo

T   :   08 9405 5318
F   :   08 9405 5349 
E   :   
AKM....@wanneroo.wa.gov.au

23 Civic Drive, Wanneroo WA 6065
Locked Bag 1, Wanneroo WA 6946
Reply all
Reply to author
Forward
0 new messages