Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.24 KB | None | 0 0
  1. import gdal, ogr
  2.  
  3. gdal.SetConfigOption('OGR_INTERLEAVED_READING', 'YES')
  4. osm = ogr.Open('finland-latest.osm.pbf')
  5.  
  6. # Grab available layers in file
  7. nLayerCount = osm.GetLayerCount()
  8. thereIsDataInLayer = True
  9. pubs = []
  10.  
  11. while thereIsDataInLayer:
  12.     thereIsDataInLayer = False
  13.     # Cycle through available layesr
  14.     for iLayer in range(nLayerCount):
  15.         lyr=osm.GetLayer(0)
  16.         lyr.SetAttributeFilter("place='village'")
  17.         for feature in lyr:
  18.             print("village",end=";")
  19.             print(feature.GetField("name"),end=";")
  20.             print("%.7f"%feature.GetGeometryRef().GetY(),end=";")
  21.             print("%.7f"%feature.GetGeometryRef().GetX())
  22.         lyr.SetAttributeFilter("place='town'")
  23.         for feature in lyr:
  24.             print("town",end=";")
  25.             print(feature.GetField("name"),end=";")
  26.             print("%.7f"%feature.GetGeometryRef().GetY(),end=";")
  27.             print("%.7f"%feature.GetGeometryRef().GetX())
  28.         lyr.SetAttributeFilter("place='city'")
  29.         for feature in lyr:
  30.             print("city",end=";")
  31.             print(feature.GetField("name"),end=";")
  32.             print("%.7f"%feature.GetGeometryRef().GetY(),end=";")
  33.             print("%.7f"%feature.GetGeometryRef().GetX())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement