我正在使用 QGIS(点层)中的 shapefile,并且我正在尝试遍历所有点,但是有些点显然没有有效的几何图形。
当我输入时,layer.getFeature(1).geometry()
我得到<QgsGeometry: null>
因此我不能使用该.asPoint()
函数但是当我遍历所有特征时,它不会显示那些具有空几何的特征:
for feature in layer.getFeatures():
print(feature.geometry().asPoint())
那么为什么在遍历所有层时没有显示任何空几何,而是第一个(实际上所有特征在使用单个特征layer.getFeature(x)
命令时都显示空几何)。有没有办法解决这个问题?