I have a .csv file that is an exported attribute table that I would like to reconstruct as a polyline shapefile (for reasons beyond my control I cannot access the original shapefile from which the .csv attribute table was exported, nor do I have access to metadata). To reconstruct the polylines, I must:

  1. Import the .csv file,
  2. Display the point data, then
  3. Connect the points in the correct order to make lines.

I am able to complete steps 1) and 2), but am having trouble with step 3).

Here is what the exported .csv attribute table looks like (hiding a few irrelevant columns): enter image description here

It seems like each row represents a line and that the field "the_geom" contains the lat/long of the points that make up the line. I've tried unsuccessfully to use the xy to line and points to line tools to reconstruct.

How can I reconstruct these lines?

  • 3
    Actually, your conversion process is: 1) Read the ASCII fields 2) Write the resulting row. That's it. The geometry is stored in Well-Known Text, from which it is trivial to generate Geometry objects. The most important part is to not do your step two, because that could wreck the geometry. To repeat, this is not a points-to-line task, this is a line to line task. Research how to convert WKT to geometry and you'll be done. – Vince Jan 3 at 1:37
  • You can easily do this in Python if you want, but I assume you are not looking for that? – Thibauld Croonenborghs Jan 3 at 10:27
  • Thank you @Vince for you advice, I researched WKT to geometry and was able to solve the problem. Here is a simple script I modified to convert. – Keanan Gleason Jan 3 at 16:55

Convert WKT to geometry using a script such as this one.

| improve this answer | |
  • 1
    Link-only answers tend to fail over time. A full answer would include a complete procedure within the answer body, with a link for reference. – Vince Jan 4 at 5:26

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.