Installing Fiona on Ubuntu 14.04


This post is more than 5 years old. While math doesn't age, code and operating systems do. Please use the code/ideas with caution and expect some issues due to the age of the content. I am keeping these posts up for archival purposes because I still find them useful for reference, even when they are out of date!

This post consists of some quick notes on installing Fiona , a Python interface to OGR, which is a tool that one might want if working with GIS data on a regular basis. I'm trying to do things like convert shapefiles to geojson-- without much luck until now (see below)-- and this is one of the tools I'm looking at as part of the solution. If you want to install Fiona on Ubuntu 14.04 follow along.

I'll be following the Fiona install instructions at github , using the Ubuntu 14.04-specific information. If you are on Windows, MAC, or another Linux flavor you should check the page for help with your OS.

So, first we need to install a library that Fiona wraps:

$ sudo apt-get install libgdal1-dev

Next, I'll use pip to install the package as a user:

$ pip install --user fiona

We can get information on the install using pip show:

$ pip show fiona
Metadata-Version: 1.1
Name: Fiona
Version: 1.6.1
Summary: Fiona reads and writes spatial data files
Author: Sean Gillies
License: BSD
Location: /home/cstrelioff/.local/lib/python2.7/site-packages
Requires: cligj, click-plugins, six

Okay, we have installed and are ready to go. I'll use the command-line script, fio, included with the package for a quick demo using the shapefile exported from Alameda County School District Boundaries . To start, lets get information about the file:

$ fio info --indent 2 UnifiedSchool.shp
"count": 29,
"crs": "+datum=NAD83 +lat_0=36.5 +lat_1=37.0666666667 +lat_2=38.4333333333 +lon_0=-120.5 +no_defs +proj=lcc +units=us-ft +x_0=2000000 +y_0=500000.0",
"driver": "ESRI Shapefile",
"bounds": [
"schema": {
"geometry": "Polygon",
"properties": {
"DIST_NAME": "str:50",
"DISTRICT_I": "int:10",
"Shape_STAr": "float:19.11",
"Shape_STLe": "float:19.11"

Finally, I will convert the shapefile into a geojson for visualizing on the web using leafletjs :

$ fio dump UnifiedSchool.shp --indent 2 --precision 2 > UnifiedSchool.json

and, checkout the result:

$ head UnifiedSchool.json
"features": [
"geometry": {
"coordinates": [

The main thing to notice is that the output has latitude and longitude values needed for leafletjs to show the regions correctly. The original shapefile did not have this formatting-- very cool! Checkout the Fiona github page for examples on how to use the package. Also, you can check out the resulting map here. Try clicking on the districts to see the name as well as playing with the visible layers (upper-right corner of map). As always, comments and questions are welcome.