[GIS] How to Convert from GMT Line files to Shapefile for QGIS

gdalgmtqgis

I have several line text-files of (used in GMT) saved in the format (this is a small sample):

-111.29 42.28
-111.29 42.31
-111.29 42.33
>
-111.37 41.99
-111.38 42.02

I am trying to convert this to a Shapefile to use in QGIS. I know people convert from shp to GMT with ogr2ogr can you do this in reverse GMT to Shp? I tried using ogr2ogr and had no luck. Maybe I did something wrong or it is not possible with that tool.

I have tried to import this format in QGIS via the delimited text layer tool, but can only figure out how to get points when I need lines.

Best Answer

ogr2ogr -F "ESRI Shapefile" data.shp data.gmt

should do the trick. Note that if you want to create a 'proper' OGR/GMT file you should include header information - see GMT Cookbook - OGR/GMT-format chapter. Thus, you might need to add a > on the first line to make sure that ogr2ogr understands that there are multiple line segments.

Good luck.

Related Question