Python GUI

General information on python development tools

There are several libraries for developing GUI's using python. My interest is in cross-platform libraries. Here are some references:

There is a comprehensive list of GUI's to use with python in GUI Programming in Python. For a list of IDE's see Integrated Development Environments for python.

Qt with python

PyQt is a Python binding of the cross-platform GUI toolkit Qt. There are other bindings too, like PySide.

Official PyQt web

Installation of PyQt4

The needed packages under a debian-like distribution are:

sudo aptitude install qt4-doc qt4-doc-html qt4-demos qt4-designer

For development with python:

sudo aptitude install python-qt4 qt4-designer  \
    pyqt-tools pyqt4-dev-tools python-qt4-gl

If using Qt-Designer version 4 the generated *.ui file should be converted to python code using pyuic4 and not pyuic (this is for Designer 3). The pyuic4 is in package pyqt4-dev-tools and pyuic is in package pyqt-tools.

Installing local help

Install the following packages to get the help installed locally:

sudo aptitude install qt4-doc qt4-doc-html qt4-demos qt4-dev-tools \
    python-qt4-doc

The installed documents are in:

There is a GUI application to browse the help files that makes it possible global searches and index: assistant-qt4

References to online documentation

Tutorials and introductions:

Tags: python

3D graphics libraries

Rendering engines OpenGL, Coin.

Python 3D libraries

VTK

Programmend in C++ but with python and java bindings. In Ubuntu install packages python-vtk vtk-doc vtk-examples vtkdata and see /usr/share/vtk/ for samples and tutorial. Recommended books are:

  • The VTK User's Guide (Kitware)
  • The Visualization Toolkit: An Object Oriented Approach to 3D Graphics
PyOpenGL
Application driven/immediate and retained mode library (OpenGLContext). Included in Ubuntu (apt-get install python-opengl).
Soya3D
Included in Ubuntu (apt-get install python-soya).
Mayavi
Scientific data visualizer written on top of VTK. Written in python. Initially created for CFD. It provides a Tkinter GUI. See also MayaVi wiki.
Coin3D
is the C++ library that can be accessed with pivy and is a high level library for 3D (retained mode) used in scientific and and engineering visualization applications.
Pivy
Wrapper for the Coin/Inventor Scenegraph Library. High Level 3D Graphics Programming in Python.
VPython
Create navigable 3D displays and animations. For those with limited programming experience.
Soya3D
Soya 3D is an object oriented "high level" 3D engine for Python.

pygame

Python-Ogre
High performance gaming and graphics library for Python.
cgkit
Python Computer Graphics Kit. Maya plugin. Exposes the Maya C++ SDK to Python Python binding of Pixar's RenderMan API. Turns Python into a scene description language which can define scenes that can then be rendered with RenderMan or OpenGL.
PyOpenGL
The Python OpenGL Binding.
OpenSceneGraph (PyOSG)
General-purpose C++ engine with Python binding.
Panda 3D
CMU/Disney collaboration on 3D game/simulation engine with python bindings.

OpenGL

Visualization Library
A lightweight C++ OpenGL middleware for 2D/3D graphics.
Blender
Programmed in C++ but with python bindings for its API.

Maya.

C++ libraries

OpenGL - Wikipedia

Free Graphics Libraries. Free Graphics Libraries, 3D/2D Engines, Image Drawing, Animation Source Code in any language (mostly C/C++). Visualization Library. A lightweight C++ OpenGL middleware for 2D/3D graphics.

Other lists of resources

3D Graphics in Python
Review of different programming paradigms and list of available libraries.
Python 3D Software
A small collection (91 packages) of pointers to Python software for working in three dimensions.

Python 3D Software

2D and 3D Graphics in Python

Python - GPWiki

Tags: 3d, graphics

VTK visualization library

The VTK (Visualization Toolkit) is an open-source library for 3D computer graphics, image processing and visualization. It is a C++ library but has bindings for python, java and other programming languages also.

These are some tutorials:

VTK related links

Tags: graphics

GIS libraries

GIS libraries for working with geometries, databases and terrain data.

See also Computational Geometry

GIS libraries

GeoTools
Open source java GIS toolkit.
PostGIS
Module for PostgreSQL to add support for geographic objects.
SEXTANTE (SIG)
Sistema EXTremeĂąo de ANĂĄlisis TErritorial (SEXTANTE) is an open source java library of algorithms for spatial analysis developed in Extremadura, Spain.
GDAL - Geospatial Data Abstraction Library

C++ Library for reading DEM files, converting. It has python and java bindings (generated with SWIG).

Mapnik C++/Python GIS Toolkit | Welcome
Mapnik is a Free Toolkit for developing mapping applications. Above all Mapnik is about making beautiful maps.
Kabeja
Kabeja is a Java library for parsing, processing and converting Autodesk's DXF format.
GeoAPI
GeoAPI provides a set of Java language programming interfaces for geospatial applications.
Quantum GIS
Quantum GIS (QGIS) is a user friendly Open Source Geographic Information System (GIS).
SAGA - System for Automated Geoscientific Analyses
System to analyze raster terrain data.
GeoDjango
Geographic Web framework to build GIS Web applications and spatially enabled data.
Geoprocessing with Python using Open Source GIS
Saple python code for reading raster DEM files and processing.

Other lists of resources about GIS

freegis.org
Free GIS resources and libraries.
PyPI
The Python Package Index has a section for GIS: Scientific/Engineering::GIS
Open Source GIS
Index of Open Source / Free GIS related software projects.
PyPi GIS section
GIS section on Python Package Index.
freshmeat
Projects tagged "Geographical" at freshmeat.net.
Open Geospatial Consortium
The Open Geospatial Consortium, (OGC) is a organization for the development of standards for geospatial and location based services.

Tags: gis

Computational Geometry

This is a list of libraries and resources I have found on computational geometry. There are libraries in C/C++, Java and python. Also some interesting books are listed and sites with other lists.

2D libraries

JTS Topology Suite

The JTS Topology Suite is a Java API for modeling and manipulating 2-dimensional linear geometry. It provides numerous geometric predicates and functions. JTS conforms to the Simple Features Specification for SQL published by the Open GIS Consortium. See also:

GEOS
GEOS (Geometry Engine - Open Source) is a C++ port of the Java Topology Suite
(JTS).
Shapely 1.2.6
Geometric objects, predicates, and operations in python. Python bindings for the GEOS library. So it is also based on JTS.
Python Imaging Library (PIL)
The Python Imaging Library (PIL) adds image processing capabilities to your Python interpreter. This library supports many file formats, and provides powerful image processing and graphics capabilities.
scipy
Scientific programming with Python. It has some support for geometric calculations.

3D libraries

CGAL - Computational Geometry Algorithms Library

C++ library of efficient and reliable geometric algorithms. Offers data structures and algorithms like triangulations in 2D and 3D, arrangements of curves, mesh generation including volumes and skin surfaces, geometry processing (surface mesh simplification), convex hull algorithms (in 2D, 3D), search structures (kd trees), interpolation, shape analysis, fitting, and distances. See also:

GTS - The GNU Triangulated Surface Library

C library to deal with 3D surfaces meshed with interconnected triangles. Construct, manipulate, and perform computations on 3D triangulated surfaces. Efficient library to scientists dealing with 3D computational surface meshes. 2D dynamic Delaunay and constrained Delaunay triangulations. Robust geometric predicates, operations on surfaces (union, intersection, difference), surface refinement and coarsening, dynamic view-independent continuous level-of-detail, bounding-boxes trees and Kd-trees, metric operations (area, volume, curvature...), Triangle strips generation for fast rendering. There are python bindings, see:

(scipy.spatial)
Spatial algorithms and data structures .

Some auxiliary libraries

Rtree
Spatial indexing for Python
NURBS library (missing link)
NURBS - Non Uniform Rational B-Splines library programmed in python.

Other lists of resources

Computational Geometry Code
"small" pieces of geometric software available on the Internet.

Computational Geometry Software Libraries :

Tags: geometry, gis

Digital elevation models (DEM)

A digital elevation model (DEM) is a digital representation of ground surface topography or terrain.

There exists a lot of different file formats for storing DEM data. The GDAL (Geospatial Data Abstraction Library) allows to read, write, convert and extract data from several DEM file types

For Spain, there is the CNIG (Centro Nacional De Información Geográfica - España) from where DEM maps with 30m resolution can be downloaded for free. This files are in Arc/Info ASCII Grid format.

Using the GDAL python bindings all this data can be read into a python program using numpy arrays for efficiency.

Sources and databases with available DEM

USGS/EROS
Earth Resources Observation and Science (EROS) Center. DEMs for USA The National Elevation Dataset (NED), Shuttle Radar Topography Mission (SRTM, 90m for world and 30m for US), DEM elevation values that have been primarily derived from the USGS topographic map series, Global 30 Arc-Second Elevation Dataset (GTOPO30).
CNIG - Centro Nacional De Información Geográfica - Spain.
MDT25 (25 m/pixel), MDT200 (200 m/pixel) The MDT25 files are *.agr (ESRI ArcInfo ASCII Grid).
View Cartographic
Has downloadable DEMs for all the world (paying). For Spain it has 90m DEMs (SRTM3 from NGA) and 90m cartographic scanned DEM (very expensive).
NASA World Wind
World Wind is an open source (released under the NOSA license) virtual globe developed by NASA and the open source community. It is a Java application and so it is cross-platform.

More reference lists

FreeGIS.org
The freegis.org site has a list of data sources of DEMs in the Geo-Data section
Digital Terrain Modeling and Mapping
Other list of DEM sources more complete than this.
MapCruzin
Free GIS Shapefiles, Software, Resources and Geography Maps. It has an entry with resources for terrain maps

Tags: gis

Backup

Backup to disk using hardlinks:

  • BackupPC: Install with sudo aptitude install backuppc.
  • Dirvish: Install with sudo aptitude install dirvish.
  • rlbackup (Remote Linked Backup): It isn't in Ubuntu's repositories.

The rdiff-backup doesn't use hardlinks for the incremental backups. It stores only one copy for current files and diff files for modified ones. Final backup takes less space (only changed parts of each file are stored and then compressed with gz), but only the last backup can be restored using standard utilities like cp.

The most current backup is a mirror of the original, but older ones must be restored by means of the own rdiff-backup script to un-apply diffs. So i think this program is more useful for directories in which most files are text files (source repositories, etc). It is very unlikely that any space can be saved by making diffs of binary files and it is more inconvenient for restoring older snapshots.

sudo aptitude install rdiff-backup

Tags: backup, linux

Extending python with C++

Python can be extended or embedded. The only option discussed here is writing extensions.

For extending python you need to write an extension module by hand or generate one automatically. Those are some of the main available options:

  • ctypes: Ctypes is a python module that load *.dll and *.so libraries dynamically and make the functions inside the library available from python. It is cross-platform. Types conversion is made at runtime making it slower but development time is much faster.
  • Write extension by hand: If there are many functions in the library it can be a hard task. Exceptions and types need to be converted explicitly.
  • swig: It parses the header file *.h and generate *.cxx c++ code that is a extension for python. Also, a python module is generated as a interface between python and the c++ library. To parse the header files can be very difficult and sometimes it is necessary to write "interface files".
  • boost::python: is a package from Boost that makes it easier to write C++ extension for python. It includes functions for common tasks like type and exception conversions.
  • pyste: is a generator for boost::python. It produces boost::python code automatically but it doesn't try to parse the *.h header files, which is a hard tasks, but instead relays on gcc to parse it and generate XML code that it ultimately use.
  • PyCXX: is another generator.

If it needs to be cross platform probably the best option is ctypes.

It seems that the better option if C++ code is being developed from scratch is to use pyste because at the C++ side the boost classes are available to interface with the python objects from C. But using pyste means that when source code is distributed the end user needs to have gcc installed. With swig you distribute the C++ *.cxx generated code

The advantage of Swig is that code to interface with several languages can be generated, not only to python. *.so files need to be stripped the symbol table to greatly reduce their size. This can't be done automatically from distutils.

References:

Tags: c, python