OGR GetX总是返回零

时间:2013-03-11 21:47:37

标签: gdal ogr

我正在尝试获取多边形的第一个x坐标。但是我只得到零回报。什么可能导致这种情况?

import os, sys, gdal, ogr
from gdalconst import *

driver = ogr.GetDriverByName('ESRI Shapefile')
testarea = driver.Open('testarea.shp', 0)
testarealyr = testarea.GetLayer()
testareafeature = testarealyr.GetNextFeature()

# get the x,y coordinates for the point
testareageom = testareafeature.GetGeometryRef()
print testareageom

x = testareageom.GetX()
print x


>>> 
POLYGON ((-124.1963006330602 43.006410659375554,-124.1861022086067 43.006647759060762,-124.1858958821004 43.00274627515271,-124.19612378176909 43.002422936639086,-124.19612378176909 43.002422936639086,-124.1963006330602 43.006410659375554))
0.0
>>> 

0 个答案:

没有答案