Tuesday, 8 August 2017

What's the proper format for WKT linestrings when importing into QGIS?



I'm trying to run the following test CSV through the Delimited Text plugin as WKT data:


oid,Line
1,LINESTRING((45.554194 -122.686101, 45.433001 -122.762632))
2,LINESTRING((45.432505 -122.598327, 45.423743 -122.592932))
3,LINESTRING((45.285959 -122.333998, 45.423743 -122.592932))
4,LINESTRING((45.548994 -122.514218, 45.519204 -122.679675))
5,LINESTRING((45.491189 -122.873493, 45.433001 -122.762632))
6,LINESTRING((45.380535 -122.743911, 45.397011 -122.79874))
7,LINESTRING((45.347019 -122.350363, 45.423743 -122.592932))
8,LINESTRING((45.582386 -122.689115, 45.536485 -122.65859))

9,LINESTRING((45.430841 -122.782667, 45.380535 -122.743911))

All I'm getting for my trouble is this error:


The layer file:///$PATHTOFILE?delimiter=%5B,%5D&delimiterType=regexp&wktField=Line is not a valid layer and can not be added to the map


I have to be missing something simple here, but I have no idea what it is, and Google hasn't been helpful. I'm using QGIS 1.8.0-Lisboa.



Answer



There are two possibilities here (see http://en.wikipedia.org/wiki/Well-known_text for more possibilities):



  1. LineString - LINESTRING (30 10, 10 30, 40 40)

  2. MultiLineString - MULTILINESTRING ((10 10, 20 20, 10 40), (40 40, 30 30, 40 20, 30 10))



Currently you have LINESTRING and (( which is wrong.


UPDATE There is also a problem with the commas as Jason says, I managed to get the following to import (once I changed the delimiter to ;):


oid;Line
1;LINESTRING(45.554194 -122.686101, 45.433001 -122.762632)
2;LINESTRING(45.432505 -122.598327, 45.423743 -122.592932)
3;LINESTRING(45.285959 -122.333998, 45.423743 -122.592932)
4;LINESTRING(45.548994 -122.514218, 45.519204 -122.679675)
5;LINESTRING(45.491189 -122.873493, 45.433001 -122.762632)
6;LINESTRING(45.380535 -122.743911, 45.397011 -122.79874)

7;LINESTRING(45.347019 -122.350363, 45.423743 -122.592932)
8;LINESTRING(45.582386 -122.689115, 45.536485 -122.65859)
9;LINESTRING(45.430841 -122.782667, 45.380535 -122.743911)

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...