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:
id,gm
0,"LINESTRING (30 10 0, 10 30 0, 40 40 5)"
I have a test.vrt file like this:
<OGRVRTDataSource>
<OGRVRTLayer name="lineWKT">
<SrcDataSource>F:\Data\lineWKT.csv</SrcDataSource>
<GeometryType>wkbLineString25D</GeometryType>
<LayerSRS>PROJCS["WGS_1984_Lambert_Conformal_Conic",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",1000000.0],PARAMETER["False_Northing",1000000.0],PARAMETER["Central_Meridian",85.875],PARAMETER["Standard_Parallel_1",24.625],PARAMETER["Standard_Parallel_2",27.125],PARAMETER["Latitude_Of_Origin",25.8772525],UNIT["Meter",1.0]]</LayerSRS>
<GeometryField encoding="WKT" field='gm' > </GeometryField >
</OGRVRTLayer>
</OGRVRTDataSource>
With this configuration, I can create a shapefile with the following command:
ogr2ogr line.shp test.vrt
CSVfile hanging around, you could add a trailing command to take out the garbage. Just append this to the command:&& rm -f dataset.csv– elrobis Jul 17 '20 at 14:15CAST ASin the SQL statement:-sql "SELECT CAST(id AS int) AS id, CAST(x AS decimal) AS x, ST_GeomFromText(geometry) AS geometry FROM .... Otherwise they will all be of type string. – hfs Sep 13 '22 at 09:42