814Adding pyproj to a buildout

2008-09-18T16:11:54Z

Pyproj is Jeffrey Whitaker's Python interface to PROJ.4. I'm no longer interested in other Python projection packages. Its most interesting feature is interoperability with packages (such as Shapely) that use the Numpy array interface. It depends on Cython, which makes it a bit tricky to include in a buildout: you must install Cython into your buildout's python, not as an egg, and make the pyproj egg only after this step is finished. Like this:

[buildout]
parts =
  cython-src
  cython-install
  pyproj

[cython-src]
recipe = hexagonit.recipe.download
url = http://cython.org/Cython-0.9.8.1.1.tar.gz

[cython-install]
recipe = iw.recipe.cmd
on_install = true
cmds =
  cd ${buildout:directory}/parts/cython-src/Cython-0.9.8.1.1
  ${python:executable} setup.py install

[pyproj]
recipe = zc.recipe.egg:eggs
index = http://atlantides.org/eggcarton/index
eggs = pyproj

You might be able to pull pyproj off PyPI, but here I am using my own index. Once built, you can try it out using zopepy:

>>> from pyproj import Proj
>>> defn_900913 = """
... +proj=merc +a=6378137 +b=6378137
... +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0
... +units=m +nadgrids=@null +no_defs
... """
>>> proj_900913 = Proj(defn)
>>> lonlat = (25.0, 25.0)
>>> proj_900913(*lonlat)
(2782987.269831839, 2875744.6243522423)

I like that projection definitions can be split across lines of the screen.

Comments are closed after 13 days.

Some rights reserved 2008 by Sean Gillies.