Skip to content

Latest commit

 

History

History
70 lines (46 loc) · 2.44 KB

Programmatically manipulate GPX data.md

File metadata and controls

70 lines (46 loc) · 2.44 KB

From Programmatically manipulate GPX data

  • osgeo.ogr can read all these formats: OGR Vector Formats
  • osgeo.ogr and shapely support 3D:
        from osgeo import ogr
        point = ogr.Geometry(ogr.wkbPoint25D)
        point.AddPoint(5,4,4)
        point.GetZ()
        4.0

        from shapely.geometry import Point
        point1 = Point(5,4,4)
        point1.has_z
        True
        point1.z
        4.0
        from shapely.wkb import loads
        point = ogr.Geometry(ogr.wkbPoint25D)
        point.AddPoint(5,4,4)
        point_shapely = loads(point.ExportToWkb())
        point_shapely.has_z
        True 
  • inverse
        point_ogr = ogr.CreateGeometryFromWkb(point_shapely.wkb)
        print point_ogr.GetX(), point_ogr.GetY(), point_ogr.GetZ()
        5.0 4.0 0.0

As one example of the process, here are the results of the creation of geological cross-sections from 3D points (from Python: Using vector and raster layers in a geological perspective, without GIS software, in French, but the scripts and the figures are universal).

3D representation (distance between points):

enter image description here

cumulative distance (geological cross-section)

enter image description here