How do you access the attributes and geometry of features in your favorite Python and GIS environment? Let's imagine we're interested in the state_name attribute from a US States data set and compare. I'll employ the iterable adapters I introduced in a previous post to simplify the code.
That's not bad at all, although there's potential for name collisions.
OGR (earlier than 1.5):
OGR (current, also known as osgeo.ogr):
Howard Butler has made osgeo.ogr much more peaceful.
A mapping of attributes is design that I like, but it could be more user friendly.
5 different environments, 5 different ways.
Ideally, feature attributes (not to be confused with Python object attributes) are accessed through a mapping attribute to prevent collisions in the feature's own namespace, and the feature geometry is simply another attribute:
Looks a bit like GeoJSON? Yes, it does.