This question is related to Converting shapefiles to text (ASCII) files?.

I have a CSV file, with one column, where all the rows correspond to WKT POLYGON()'s:


I'm familiar with how to convert from shapefile to wkt, but I need to go the other way around. How to accomplish this task?

I tried playing around with ogr2ogr's settings/flags but didn't really get anything useful.

I also know I can use QGIS to do this, but it freezes/crashes since the dataset is fairly large.


http://www.gdal.org/drv_vrt.html plus http://www.gdal.org/drv_csv.html should have everything you need to describe the layout of your data and import it. In short, you need to create a OGR VRT file that describes things using details from the CSV driver page.

| improve this answer | |

I had to solve the same problem today, so here is my answer, which gives a complete solution.

I have a lineWKT.csv file stored in F:\Data\ folder, with the data like this:

0,"LINESTRING (30 10 0, 10 30 0, 40 40 5)"

I have a test.vrt file like this:

    <OGRVRTLayer name="lineWKT">
 <GeometryField encoding="WKT" field='gm' > </GeometryField >

With this configuration, I can create a shapefile with the following command:

ogr2ogr line.shp test.vrt

| improve this answer | |
  • 1
    great and working method! thanks for sharing some code as well. – umbe1987 Apr 24 at 14:37

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.