Fiona 0.9

It's tagged and uploaded to PyPI.

Here's a quick example that demonstrates a couple new features: support for variable fixed text field width and mixing of single and multipart one and two-dimensional geometric objects (linestrings and multilinestrings; polygons and multipolygons) in Shapefiles.

>>> c = fiona.open('ne_110m_geography_regions_polys.shp', 'r')

The fiona.open function is the new way to get an open collection, but the old fiona.collection function still works. Keep in mind that the first parameter of fiona.open (the path) is the only positional parameter. All others are keyword parameters, but it's fine to treat the mode, the 2nd parameter in the function definition, as a positional parameter as I did above.

>>> c.name
'ne_110m_geography_regions_polys'
>>> c.mode
'r'
>>> c.closed
False

A collection has a few file-like properties.

>>> c.crs
{'no_defs': True, 'ellps': 'WGS84', 'datum': 'WGS84', 'proj': 'longlat'}
>>> c.driver
'ESRI Shapefile'
>>> import pprint
>>> pprint.pprint(r.schema)
{'geometry': 'Polygon',
 'properties': {u'featurecla': 'str:32',
                u'name': 'str:254',
                u'namealt': 'str:254',
                u'region': 'str:50',
                u'scalerank': 'float',
                u'subregion': 'str:50'}}

The collection describes itself as containing records with polygon type geometries and six properties. Five of those properties are str (text) type, with maximum lengths of values being 32 ('str:32') to 254 ('str:254') characters.

>>> records = list(r)
>>> len([r for r in records if r['geometry']['type'] == 'Polygon'])
52
>>> len([r for r in records if r['geometry']['type'] == 'MultiPolygon'])
8

There are 52 records with polygon type geometries in this file and 8 with multipolygons.

All the Fiona examples, including the one only for functional programming geeks, are updated for version 0.9. So is the manual.

I've been remiss in pointing out a couple good blog posts about using Fiona. Tom MacWright wrote GIS with Python, Shapely, and Fiona last fall (widely linked, Tom's reach is huge), and Steve Citron-Pousty wrote Using Open Source GIS tools for spatial data - QGIS, GDAL and Python just the other day. I'm excited to see creative and super productive programmers putting Fiona to work and writing about it.