Quantcast
Channel: Question and Answer » gdal
Viewing all articles
Browse latest Browse all 397

OGR FeatureCount returns '-1' with OSM data

$
0
0

I am trying to read in an OSM file with OGR.

import ogr
driverOSM = ogr.GetDriverByName('OSM')
roadsDs = driverOSM.Open('data/map.osm', 0)
roadsLayer = roadsDs.GetLayer()

The feature count returns -1

print roadsLayer.GetFeatureCount()

When I loop over the features only points are returned, eventhough I know there are ways too (tested the data in QGIS).

featureStand = roadsLayer.GetNextFeature()
while featureStand:
  geomStand = featureStand.GetGeometryRef()
  print geomStand
  featureStand.Destroy()
  featureStand = roadsLayer.GetNextFeature()

Can anybody reproduce that or sees what I am doing wrong?


Python 2.7.5, GDAL 1.10.1, did not modify osmconf.ini


Viewing all articles
Browse latest Browse all 397

Trending Articles