When I try to access one of the GRASS vector files through Python OGR bindings, it gives error:

Here is the script code in Python 2.7.3 IDLE (GUI) in Windows 7.

from osgeo import ogr
ds = ogr.Open('D:/UEL/GrassGISDB/SLD99/LBS/vector/CluterCleaned/head')
layer = ds.GetLayer(0)

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    layer = ds.GetLayer(0)
AttributeError: 'NoneType' object has no attribute 'GetLayer'

When i print ds, it is None. I think problem lies in the ds. Any help?

  • 1
    Is your folder path spelled correctly? It looks like there's a folder in it that should be spelled "ClusterCleaned" or "ClutterCleaned" not "CluterCleaned". Though that is a guess, obviously.
    – Fezter
    Commented Dec 22, 2012 at 19:45

1 Answer 1


OGR is unable to open your dataset. Check that the dataset exists, the path is correct and that you have a version of GDAL/OGR with GRASS vector support as it is not compiled by default.

To check if you have GRASS vector support, type ogrinfo --formats at a command prompt.

  • Yes, My windows version of GRASS (i.e. GRASS 6.4.3svn) does not have GRASS vector support. Any idea to add it?
    – Sanjeewa
    Commented Dec 22, 2012 at 20:58
  • I don't know, try asking a new question. Make sure you specify what version of GDAL/OGR you have and where you got it from (i.e OSGeo4W, GISInternals, FWTools, etc...)
    – user2856
    Commented Dec 23, 2012 at 0:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.