I am trying to open a *.osm file in Python with GDAL. But I doesn't work. What am I doing wrong?
import ogr
driver = ogr.GetDriverByName('OSM')
datasource = driver.Open('map.osm')
layer = datasource.GetLayer()
Error looks like this
>>>
Traceback (most recent call last):
File ".../osm_reader.py", line 3, in <module>
datasource = driver.Open('map.osm')
AttributeError: 'NoneType' object has no attribute 'Open'
I exported the data directly from the OSM Website.
My Python Version is 2.7.5.
About my GDAL Version I am not sure. And this might be the problem.
Easy Install says
U:\>easy_install GDAL
Searching for GDAL
Best match: GDAL 1.10.1
Adding GDAL 1.10.1 to easy-install.pth file
Using c:\python27\lib\site-packages
GDAL Version says
>>> gdal.VersionInfo()
'1810'
Does 1810
mean GDAL 1.10.1? How do I get this to work?
Best Answer
This means indeed that the GDAL version Python is using is GDAL 1.8. So I re-installed GDAL for Python with this installation.
After that the GDAL version was up to date (1.10.1).
Though now I got a new error:
After copying the
osmconf.ini
into my working directory it finally worked.