Creating a line from excel file

812 views
Skip to first unread message

Zaved

unread,
Jun 18, 2008, 1:45:27 AM6/18/08
to MapInfo-L
Hi,
I want to create a line from excel file in mapinfo. The excel file
format is as below:

site1 site2 site1_latitude site2_latitude site1_longitude
site2_longitude

Can anyone help me, how can I create a line from the above format in
mapinfo?

BR//
Zaved

Pete

unread,
Jun 18, 2008, 3:18:15 AM6/18/08
to MapInfo-L
Hi Zved,

Use MapInfo Pro Help. Type "create points from an excel" in the
search.

You open an excel table in MapInfo simply by opening a table (change
the file type to an xls file).

Following the instructions and go to the next page (use the arrows) to
learn how to create points from the data.

Once you have the points in MapInfo then you can use the snap feature
(press S in the MI map window) and join the points with a polyline (or
line).

That is the simplest way I can think of doing it (and do it).

Pete

Driver, Greg 9434

unread,
Jun 18, 2008, 4:01:58 AM6/18/08
to mapi...@googlegroups.com
Furthermore, if you want to create a line then you just need to open
the MapBasic window (Options -> Show MapBasic Window) and then enter the
following:


Set coordsys table tablename
Update Tablename set obj = Createline(site1_longitude ,site1_latitude
,site2_longitude ,site2_latitude )

Before doing the above you'll need to make the table 'mappable' through
Table -> Maintenance -> Table Structure and tick the 'Table is Mappable'
option. At this point you can also select the correct projection, if
you haven't set one as the default.

If your lat/long coordinates aren't in decimal degrees then you'll have
to convert them first and you can use the Degree Converter tool that
comes with MapInfo (under Tools -> Tool Manager) to do this.

HTH

Greg Driver

System Administrator
Applications Support
ICT
Surrey Police
NOT PROTECTIVELY MARKED

Hi Zved,

Pete

*Internet communications are not secure and therefore Surrey Police does not accept legal responsibility for the contents of this message. This email and any attachments may be confidential. They may contain privileged information and are intended for the named addressee (s) only. They must not be distributed without our consent. If you are not the intended recipient, please notify us immediately and delete the message and any attachments from your computer, do not disclose, distribute, or retain this email or any part of it. Unless expressly stated, opinions in this email are those of the individual sender, and not of Surrey Police. We believe but do not warrant that this e-mail and any attachments are virus free. You must therefore take full responsibility for virus checking. Surrey Police reserves the right to monitor all email communications through their networks.*

Zaved Yusuf

unread,
Jun 18, 2008, 4:18:19 AM6/18/08
to mapi...@googlegroups.com
Hi Greg,
 
Thank you very much. After wriiten this program to map basic...how can i run this?
 
BR//
Zaved

 

Driver, Greg 9434

unread,
Jun 18, 2008, 4:48:04 AM6/18/08
to mapi...@googlegroups.com
Zaved,
 
You can run the code from the MapBasic window by copying each line and then press the 'enter' key.  Don't forget to change 'tablename' to the name of the table you are working with.

Zaved Yusuf

unread,
Jun 18, 2008, 4:49:28 AM6/18/08
to mapi...@googlegroups.com
Hi Greg,
 
Thanks a lot. I have done it.

Das Suvarthi

unread,
Jun 21, 2017, 1:38:47 PM6/21/17
to MapInfo-L
Hi, thanks for the instruction to create line betn 2 coordinates. Now, for each line (connecting a pair of lat, long), I have another value in the excel table. I want to colour each line as per their value in the table. How can I do that ? Should I require to create thematic ? Hope my question is understandable..

Sancarn

unread,
Jun 21, 2017, 7:28:12 PM6/21/17
to MapInfo-L
I'm sad to say that this is a lot more complicated. Unless there's a function I don't know about...

As far as I know to color lines each in a different color you have 2 options:

1. You programatically create a theme - this can be done in the MapBasic Window.
2. You can modify styles but only for 1 object at a time so you might want to use an MBX for this.

In the MapBasic window:
Dim line as object line = CreateObject(<startX>,<startY>,<endX>,<endY>)
update <yourTable> set obj = line
Alter line Info 2, MakePen(1, 2, <yourColor>)

If running from an MBX use this function:

Function ChangeColor( ByVal oTarget As Object, ByVal penNew As Pen) As Object
  Alter oTarget Info 2, newPen
  ChangeColor = oTarget
End Function

ktgcad

unread,
Jun 21, 2017, 8:57:14 PM6/21/17
to mapi...@googlegroups.com
Thematic creation can be done. 


-------- Original message --------
From: Das Suvarthi
Date:21/06/2017 11:05 PM (GMT+05:30)
To: MapInfo-L
Subject: Re: [MI-L] Re: Creating a line from excel file

Hi, thanks for the instruction to create line betn 2 coordinates. Now, for each line (connecting a pair of lat, long), I have another value in the excel table. I want to colour each line as per their value in the table. How can I do that ? Should I require to create thematic ? Hope my question is understandable..

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

David Sherrod

unread,
Jun 22, 2017, 11:06:23 AM6/22/17
to mapi...@googlegroups.com
Using pulldown menus or mapbasic, you could query your table, selecting all lines that have that value. Then choose the line color, and it is assigned to all the lines of that selection suite.

As SQL pulldown, for example, select from MYTABLE, where KEYCOLUMN = value of choice.
(If integer, then it's that easy. If text string, put the value in quotes.)

Rinse and repeat until all your lines are color-coded as desired. Save the table. Your color choices have become a permanent part of the table appearance.

Andrew Harfoot

unread,
Jul 3, 2017, 11:32:20 AM7/3/17
to mapi...@googlegroups.com
To add to this, if you are doing this via MapBasic, and you create your object using one of the object construction functions then it will take on the currently set style, leading to a sequence of code as follows:

Select all Excel rows that need to be styled similarly
Set the current style to whatever desired
Create objects from the Excel coordinate data

eg.
select * from XL where MyVal = 3 into ToStyle noselect
set style pen (2,7,16711935)
Update ToStyle  set obj = createline(X1,Y1,X2,Y2)

select * from XL where MyVal = 5 into ToStyle noselect
set style pen (2,7,255)
Update ToStyle  set obj = createline(X1,Y1,X2,Y2)
etc...
-- 
Andy Harfoot

GeoData Institute
University of Southampton
Southampton
SO17 1BJ

Tel:  +44 (0)23 8059 2719

www.geodata.soton.ac.uk
Reply all
Reply to author
Forward
0 new messages