kjordahl/geopandas — pull request #55 by kjordahl (2013-11-03 21:30:08+00:00)
Title: Add coordinate indexing

This is a new API for slicing `GeoSeries` objects by coordinates. This implements a new indexer that uses the `cx` attribute for slicing by coordinates, analogous to `ix` for slicing by index. Slices on `cx` will return all geometries that intersect the bounding box defined by the sliced coordinates.

Examples:

>>> g = GeoSeries([Point(1.0, 1.0), Point(2.0, 1.0), Point(1.0, 2.0), Point(2.0, 2.0)])
>>> g
0 POINT (1.0000000000000000 1.0000000000000000)
1 POINT (2.0000000000000000 1.0000000000000000)
2 POINT (1.0000000000000000 2.0000000000000000)
3 POINT (2.0000000000000000 2.0000000000000000)
dtype: object
>>> g.cx[:, :1.0]
0 POINT (1.0000000000000000 1.0000000000000000)
1 POINT (2.0000000000000000 1.0000000000000000)
dtype: object
>>> g.cx[2:, 2:]
3 POINT (2.0000000000000000 2.0000000000000000)

A `step` (stride) is not handled, since coordinate intervals are continuous.

This is a preliminary implementation, open for discussion on the interface.