This document describes a GeoJSON-like protocol for geospatial vector data.
Python has a number of built-in protocols (descriptor, iterator, etc). A very simple one involves string representations of objects. The built-in str() function delegates to the __str__() method of its single argument. Example:
>>> class A(object): ... def __str__(self): ... return "Eh!" ... >>> a = A() >>> str(a) 'Eh!' >>> "%s" % a 'Eh!'
By implementing __str__(), instances of any class can be printed by any other Python program. What if we could do something like this for geospatial (GIS) objects? It might, for example, let any object be analyzed using Shapely as
simply as:
>>> from shapely.geometry import shape >>> shape(obj).buffer(1.0).area # obj is a "point" of some kind 3.1365484905459389
Shapely's shape() function would access relevant data of its single argument using an agreed upon method or attribute.
Following the lead of numpy's Array Interface [1], let's agree on a __geo_interface__ attribute.
[1] http://docs.scipy.org/doc/numpy/reference/arrays.interface.html