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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s