1

我有以下创建点几何的脚本。如何将此点几何转换为仅包含坐标的列表[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)
4

2 回答 2

3

通常一个点对象有 xyz 坐标。

[point_geom.x, point_geom.y]
于 2013-03-07T04:28:22.240 回答
0

假设 point_geom 是字面意思"POINT (258432.79138201929 1001957.4394514663)"(即字符串)

你可以做:

map(float,point_geom[7:-1].split(' '))

point_geom[7:-1]"258432.79138201929 1001957.4394514663" point_geom[7:-1].split(' ')Give将字符串强制转换为['258432.79138201929', '1001957.4394514663'] map(float,point_geom[7:-1].split(' '))浮点数

于 2013-03-07T02:43:53.183 回答