Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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 Dec 22 '12 at 19:45
Thanks, the path is correct. – Sanjeewa Dec 23 '12 at 18:25
up vote 3 down vote accepted

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.

share|improve this answer
Yes, My windows version of GRASS (i.e. GRASS 6.4.3svn) does not have GRASS vector support. Any idea to add it? – Sanjeewa Dec 22 '12 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...) – Luke Dec 23 '12 at 0:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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