Fiona
The Fiona library provides a simple Python API around the OGR library for data access and nothing more. This approach makes it easy to use and is less verbose than OGR while using Python. Fiona outputs GeoJSON by default. You can install fiona through conda.
As an example, we’ll use the GIS_CensusTract_poly.shp file from the dbfpy example we looked at earlier in this chapter.
First, we’ll import fiona and Python’s pprint module to format the output. Then, we’ll open the shapefile and check its driver type:
import fiona
from pprint import pprint
f = fiona.open("GIS_CensusTract_poly.shp")
f.driver
ESRI Shapefile Next, we’ll check its coordinate reference system and get the data bounding box, as shown here:
f.crs
{'init': 'epsg:4269'}
f.bounds We’ll see the coordinates of the bounding box as follows:
(-89.8744162216216, 30.161122135135138, -89.1383837783784, 30.661213864864862)
Now, we&...