Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a CSV file where one line looks like this:

Duration, user, lat-start, long-start, lat-end, long-end
298, Casual,38.9101,-77.0444,38.91554,-77.03818

Each row in the CSV has two points and I need to draw a line between those two points for each row. How can I do this? I have tried using the delimited text file plug-in, but it just draws points and has no line option from what I can see.

Thanks for you answer!

share|improve this question
    
What software are you using? –  Nick Ochoski Jun 28 '13 at 15:46
    
@Radar qgis 1.8.0 –  lindzcook Jun 28 '13 at 15:50
add comment

2 Answers 2

With a bit of text processing (maybe in Excel), you can bring your data into this form:

Duration;user;wkt
298;Casual;LINESTRING(-77.0444 38.9101,-77.03818 38.91554)

which can be interpreted by QGIS as well known text (WKT) using Add delimited text layer.

Note that you need blanks and comma as delimiters for lon&lat values and linestring members, and lon values have to be first. In the dialogue, only check semicolon as column delimiter.

Applying EPSG:4326 as CRS , you end up at New Hampshire Avenue Nordwest in Washington DC.


EDIT

this one works from your second example:

seconds-total;Subscription-Type;gis-data
298;Casual;LINESTRING(-77.0444 38.9101,-77.03818 38.91554)
27926;Casual;LINESTRING(-77.0444 38.9101,-77.03818 38.91554)
214;Casual;LINESTRING(-77.0511 38.8573,-77.051516 38.848441)
960;Subscriber;LINESTRING(-77.024649 38.936043,-77.012289 38.915417)
378;Subscriber;LINESTRING(-77.04062 38.917761,-77.0471 38.9054)
2085;Subscriber;LINESTRING(-77.041606 38.904742,-76.9862 38.8803)
441;Subscriber;LINESTRING(-77.094875 38.88786,-77.10108 38.884616)
456;Subscriber;LINESTRING(-77.023086 38.8997,-77.022155 38.912719)
share|improve this answer
    
I started with this strategy, thanks so much for the help! I was able to change it to this format in Excel easily. Now, waiting for it to load. It's been the beach ball of death for about 10 mins which makes me think I may have too much data. How much data usually works? Do you think it will eventually show if I wait it out or should I restart? My csv has 365,000 rows or something. –  lindzcook Jun 28 '13 at 17:08
    
I have not yet worked with such huge files, but that amount would better be put into a postgis database. Switching off rendering could improve speed. –  Andre Joost Jun 28 '13 at 19:23
    
I tried it with a small amount of data to see if the size was the problem. When I try layer, add delimited text layer with the information below, it tells me it can not add the layer because it is not valid. What am I doing wrong here? –  lindzcook Jun 28 '13 at 19:46
    
seconds-total Subscription Type gis-data 298 Casual LINESTRING(-77.0444 38.9101,-77.03818 38.91554) 27926 Casual LINESTRING(-77.0444 38.9101,-77.03818 38.91554) 214 Casual LINESTRING(-77.0511 38.8573,-77.051516 38.848441) 960 Subscriber LINESTRING(-77.024649 38.936043,-77.012289 38.915417) 378 Subscriber LINESTRING(-77.04062 38.917761,-77.0471 38.9054) 2085 Subscriber LINESTRING(-77.041606 38.904742,-76.9862 38.8803) 441 Subscriber LINESTRING(-77.094875 38.88786,-77.10108 38.884616) 456 Subscriber LINESTRING(-77.023086 38.8997,-77.022155 38.912719) –  lindzcook Jun 28 '13 at 19:46
1  
Using blanks as delimiters is not a good idea, as lon and lat have to be separated by that (and blanks in column names may also lead to trouble). See my extended answer. –  Andre Joost Jun 29 '13 at 4:18
show 2 more comments

As an alternative to Andre's very workable and straight-forward solution, you could use either the 'Points To One'or "Points To Path" plugins (install by going Plugins->Fetch Python Plugins). You have the user ID which can be your line ID. You will need to separate out your start and end points to make sure they are separate points (as it appears your data for each two-point line is in one row).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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