Split features from OGR/GMT file into separate files

Added by Andreas about 1 year ago

Say I have an OGR/GMT file, e.g.

>
3 45
4 46
5 47
>
3 76
2 65
1 65
>
3 87
1 67
3 67

and I would like to split this into one file per feature. In the case above, this would result in three files:

file1.gmt

>
3 45
4 46
5 47

file2.gmt

>
3 76
2 65
1 65

file3.gmt

>
3 87
1 67
3 67

What would be the best way to do this? I was seeking help from gmt select but I could not find any.


Replies (1)

RE: Split features from OGR/GMT file into separate files - Added by Andreas about 1 month ago

For others having the same question;

Use csplit, e.g.:

csplit --elide-empty-files --quiet --prefix=split_ C.gmt "/>/0" "{*}" 

(1-1/1)