I’m doing some scripts in Python to deal with shapefiles, and I have an issue I don’t understand. I’m looping over a shapefile, and I want to retrieve the geometry of each feature, but very often I get an error saying:
pointGeo = pointFeat.GetGeometryRef()
AttributeError: 'NoneType' object has no attribute 'GetGeometryRef'
Here’s the way I did it:
for j in range(pointsLayer.GetFeatureCount()):
pointFeat = pointsLayer.GetNextFeature()
pointGeo = pointFeat.GetGeometryRef()
if pointGeo.Within(whatever):
...
I don’t think my shapefile is corrupted or damaged, as I tried with several… and I often get this error, but for some features I don’t get it.
Any idea how to solve this?
Thanks