kjordahl/geopandas — pull request #60 by jtratner (2013-11-06 04:06:07+00:00)
Title: Allow arbitrary geo col name AND add set_geometry method to DataFrame

There are a bunch of changes here, but in sum they make it so that the
GeoDataFrame isn't bound to the name `geometry` for dealing with
geometric data. It also changes the default for drop to False.

* GeoDataFrame constructor accepts a 'geometry' kwarg that can be either a
column name (in which case that column is set as geometry) or a
compatible array (in which case the array is set as the geometry on the
object).
* GeoDataFrame gets a `_geometry_column_name` which is set to the
current geometry column.
* By default, set_geometry doesn't drop if you specify a column (just
swaps the geometry). If you pass `drop=True`, it renames the column to
geometry and resets the internal name for geometry column.
* `set_geometry` accepts a crs so you can pass the crs that matches your
the new geometry.
* binds `set_geometry` method to `pandas.DataFrame` that allows
conversion of a DataFrame to a GeoDataFrame. E.g.:
`gf = df.set_geometry('location', crs=some_crs)` though this could
potentially let you do something like load data from a file with
pandas methods, then load another set of data with geometries, merge
them on something, then use set_geometry() to get to GeoDataFrame.

Future TODO based on this: have some way to keep track of geometry
columns, because once you change the geometry name only that column
comes out as GeoSeries.

Using a GeoSeries with non-matching index in the constructor
may lead to weird results, but I don't think it's worth getting into
yet.