Essential Python Geospatial Libraries

I recently posted something on my other blog about Essential Python Geospatial Libraries, and thought that it might also be useful to the Spatial Demography community. The following is a list of Python packages that I (and others) regularly use for handling, exploring, analyzing, and generally mucking about with spatial data.

  • pandas – For data handling and munging. This is an extremely powerful tool for working with data in a spreadsheet-like format. If you’re familiar with R data.frames, then you’ll love pandas.
  • shapely – For geometry handling. This is the de facto  package for geometry handling and manipulation.
  • cartopy – For plotting spatial data. This is a pretty new package, and is actively being developed. It makes for really nice publication quality maps already, and plays really nicely with shapely geometries and matplotlib (see below).
  • rtree – For efficiently querying spatial data. This is a relatively simple spatial index package that really speeds up spatial bounding box queries.
  • nodebox-opengl – For playing around with animations. Everyone loves animations, and this package makes it pretty easy to create some simple, interactive animations.
  • statsmodels – For models and stats in Python. The group behind this project is trying to make Python just as easy and powerful for stats as R currently is… and they are making excellent headway already.
  • numpy – For pretty much anything that involves arrays. The is probably the most important package for data analysis in Python.
  • geopy – For geolocating addresses and things like that. It is a small wrapper around various web-based geocoding APIs.
  • ipython – For a wonderful interactive Python environment in which to play. It makes working with Python a true joy.
  • ogr/gdal – For reading, writing, and transforming geospatial data formats. This has all sorts of nice ways to work with geospatial data, though fiona (see below) is much nicer for reading and writing different geospatial formats.
  • pyqgis – For anything and everything GIS. This is the Python API for Quantum GIS. You can work directly within QGIS via its intergrated Python console, or create standalone GIS apps using this powerful Python package.
  • fiona – For making it easy to read/write geospatial data formats. Really, really nice API for reading and writing GIS formats.
  • matplotlib – For all your plotting needs. The de facto plotting library for Python. It does everything from scatterplots and histograms to choropleth maps to complex interactive visualizations.
  • networkx – For working with networks. Very nice for visualizing (integrates with matplotlib) and working with network data.
  • pysal – For all your spatial econometrics needs (and more). This is a really great package that is also under constant development. It covers everything from exploratory spatial data analysis (ESDA) right up to heavy duty spatial econometric models.
  • descartes – For plotting geometries in matplotlib. This is a nice, clean, GeoJSON style data helper for matplotlib and shapely.
  • geographiclib – For solving geodesic problems. It also converts between geographic, UTM, UPS, MGRS, geocentric, and local cartesian coordinates, and even does geomagnetic field calculations.
  • pyshp – For reading and writing shapefiles in pure Python. Nice API and works great.
  • pyproj – For conversions between projections. This package provides an intuitive way of interacting with the Proj4 library for transforming data between coordinate reference systems.

It is also probably a good idea to mention scipy, which is a Python-based ecosystem of open-source software, and includes things like numpy, matplotlib, ipython, pandas, and much more.

The best way to start exploring and working with these various packages is to create a Python virtual environment, and use pip or easy_install to grab the latest versions.

Happy coding!

This entry was posted by Carson Farmer on July 19, 2013 in Forum and tagged , ,

About Carson Farmer

Carson J. Q. Farmer is an assistant professor of GIScience at Hunter College – City University of New York (CUNY) and deputy director of the Center for Advanced Research of Spatial Information (CARSI). His research interests span a wide range of topics in computational social science, with a focus on spatial-temporal dynamics, complexity, and spatial interaction.