Tuesday 5 March 2019

convert - Converting CSV file of WKT data to shapefile using ogr2ogr?


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:


WKT
POLYGON(...)
POLYGON(...)
...


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.



Answer



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.


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...