Wednesday, 16 August 2017

grass - OGR Python bindings


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 "", line 1, in
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?



Answer



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.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...