Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import gdal, ogr
- gdal.SetConfigOption('OGR_INTERLEAVED_READING', 'YES')
- osm = ogr.Open('finland-latest.osm.pbf')
- # Grab available layers in file
- nLayerCount = osm.GetLayerCount()
- thereIsDataInLayer = True
- pubs = []
- while thereIsDataInLayer:
- thereIsDataInLayer = False
- # Cycle through available layesr
- for iLayer in range(nLayerCount):
- lyr=osm.GetLayer(0)
- lyr.SetAttributeFilter("place='village'")
- for feature in lyr:
- print("village",end=";")
- print(feature.GetField("name"),end=";")
- print("%.7f"%feature.GetGeometryRef().GetY(),end=";")
- print("%.7f"%feature.GetGeometryRef().GetX())
- lyr.SetAttributeFilter("place='town'")
- for feature in lyr:
- print("town",end=";")
- print(feature.GetField("name"),end=";")
- print("%.7f"%feature.GetGeometryRef().GetY(),end=";")
- print("%.7f"%feature.GetGeometryRef().GetX())
- lyr.SetAttributeFilter("place='city'")
- for feature in lyr:
- print("city",end=";")
- print(feature.GetField("name"),end=";")
- print("%.7f"%feature.GetGeometryRef().GetY(),end=";")
- print("%.7f"%feature.GetGeometryRef().GetX())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement