This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

QGIS OSMPlugin attributes

1
1

Hi,

I want to load OSM data into QGIS with the OSMPlugin. It works fine, the only problem is that all the tags are saved in one column. Is there a way to seperate each tag into one column besides the defautl ones (name, place, highway, etc.)?

Thanks,

Uli

asked 01 Nov '12, 09:30

Wasus's gravatar image

Wasus
346161725
accept rate: 0%


One Answer:

0

One possible solution is to save the osm file to a shapefile, open it in ArcGIS, and seperate the one column into several columns with the following python field calculator code:

def parseAddr(textRaw, addrTag):
  #addrTag = 'addr:city'
  text = textRaw.replace('"','')
  lstTags = text.split(',')
  for i in range(0, len(lstTags)):
    lstSingleTag = lstTags[i].split('=')
    if addrTag == lstSingleTag[0]:
      tag = lstSingleTag[lstSingleTag.index(addrTag)+1]
      return tag

Then expression for city field would be: City = parseAddr('!FieldName!', 'addr:city')

For streets field: Street = parseAddr('!FieldName!', 'addr:street')

answered 05 Dec '12, 12:55

Wasus's gravatar image

Wasus
346161725
accept rate: 0%

edited 05 Dec '12, 12:56

Source code available on GitHub .