def get_fields_as_dict(layer, key_field='Name', rename_map={
    'Latitude': 'lat', 'Longitude': 'lon', 'URL': 'url',
    'Folder': 'collection', 'Thumb': 'thumbnail', 'ImageCaptu': 'captured_at'
}):
    """Given an OGR layer, builds a dictionary containing the fields for each
    feature.  In each dictionary item, the key is the specified key_field and
    the value is a dictionary containing the rest of the fields, optionally
    renamed according to the given rename_map."""
    results = {}
    for i in range(layer.GetFeatureCount()):
        feature = layer.GetFeature(i)
        value = dict((rename_map.get(field, field), feature.GetField(field))
                     for field in feature.keys())
        results[value.pop(key_field)] = value
    return results