Search code examples
pythongeometrytuplesgdalogr

Convert Point Geometry to list


I have the following script that creates a point geometry. How can I convert this point geometry to a list only containing the coordiantes to look like [258432.79138201929, 1001957.4394514663]?

>>> import ogr
>>> driver = ogr.GetDriverByName('ESRI Shapefile')
>>> pointshp = driver.Open('U:/My Documents/Tool/shp/point.shp', 0)

>>> pointlyr = pointshp.GetLayer()

>>> point_geom = point.GetGeometryRef()

>>> print point_geom

POINT (258432.79138201929 1001957.4394514663)

Solution

  • Usually a point object has xyz coordinates.

    [point_geom.x, point_geom.y]