OGR2OGR in the 3rd dimension

I had to convert shapefile data from 2D lines/points to files consisting of 3 fields (x,y,z) for further processing using the GMT5. I was about to write some Python code to do that myself when I realised a new (GDAL >1.8) option in the ogr2ogr tool:

   -zvalue Uses the specified field to fill the Z coordinate of geometries.

Turning an attribute from a shapefile into a z-Value for GMT files ogr2ogr and this flag is easy and helps to avoid ArcGIS’ 3D Analyst’s “Feature Attribute to Z-Value” function.

Simple usage:

ogr2ogr -F"GMT" OutFileWithZValues.gmt InFileWithZAttribute.shp -zfield"Thickness"

Done. Even works the other way around: from an OGR GMT file with Z-values in the 3rd column to a 2.5D shapefile:

ogr2ogr -F"ESRI Shapefile" OutFileWithZAttribute.shp InFileWithZValues.gmt -nlt LINESTRING25D