2

I am using fiona to read a shapefile, but not sure about how to get field aliases. Is this possible using this great library?

2
  • 2
    Shapefiles don't have field aliases. GIS software can generate documents which contain aliases, but you'd have to specify which software in the question.
    – Vince
    Commented Oct 20, 2014 at 17:47
  • Ahh ok, that was my worry, obviously I'm coming from an ArcGIS background. Thanks.
    – bcollins
    Commented Oct 20, 2014 at 18:50

1 Answer 1

2

No, there is no SQL-ish select field as alias feature in Fiona. Fiona maps a shapefile's schema to a Python dict and dicts have exactly one key per value. But you can sort of alias by binding new Python names to key values.

>>> a = {'long long key': 1}
>>> a['long long key']
>>> mykey = 'long long key'
>>> a[mykey]
1

That's as close as you can get.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.