2

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?

user2856
  • 65,736
  • 6
  • 115
  • 196
Sanjeewa
  • 660
  • 4
  • 17
  • 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 Dec 22 '12 at 19:45

1 Answers1

3

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.

user2856
  • 65,736
  • 6
  • 115
  • 196
  • 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...) – user2856 Dec 23 '12 at 00:29