From d48c0ec0d14fd52e47ce7a7b5455027916c9604a Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Sun, 6 Jul 2014 18:19:13 -0500 Subject: [PATCH 01/21] RLS: Set release = True! --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fe309ae..3f9e90d 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ such as PostGIS. MAJOR = 0 MINOR = 1 MICRO = 0 -ISRELEASED = False +ISRELEASED = True VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO) QUALIFIER = '' From bd664b54d493e6a3cb3ed16aaf625bf9c23bad6f Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Sun, 6 Jul 2014 18:26:48 -0500 Subject: [PATCH 02/21] BLD: Set default version in __init__.py --- geopandas/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geopandas/__init__.py b/geopandas/__init__.py index 3f2a276..9cedc51 100644 --- a/geopandas/__init__.py +++ b/geopandas/__init__.py @@ -1,7 +1,7 @@ try: from geopandas.version import version as __version__ except ImportError: - __version__ = '0.1.0.dev-unknown' + __version__ = '0.1.0' from geopandas.geoseries import GeoSeries from geopandas.geodataframe import GeoDataFrame From 44e24314e4fa77a900424c75744e01b5ea86f869 Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Sun, 6 Jul 2014 18:27:33 -0500 Subject: [PATCH 03/21] DOC: Bump release version --- doc/source/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index d1524ee..18d2e0b 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -41,7 +41,7 @@ master_doc = 'index' # General information about the project. project = u'GeoPandas' -copyright = u'2013, GeoPandas developers' +copyright = u'2013-2014, GeoPandas developers' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -52,7 +52,7 @@ try: version = release = d['version'] except: # FIXME: This shouldn't be hardwired, but should be set one place only - version = release = '0.1.0.dev' + version = release = '0.1.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. From f6ed51f0cee2e4fae15870f18c1f1123e2f2e727 Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Sun, 6 Jul 2014 18:28:24 -0500 Subject: [PATCH 04/21] DOC: Clarify installing released version vs. dev versions --- doc/source/install.rst | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/doc/source/install.rst b/doc/source/install.rst index 7b62299..3fc2467 100644 --- a/doc/source/install.rst +++ b/doc/source/install.rst @@ -1,14 +1,23 @@ Installation ============ -GeoPandas is continuous-release software. You may install the latest -source from `GitHub`_ and use the setup script:: +The released version of GeoPandas is 0.1. To install the released +version, use ``pip install geopandas``. +You may install the latest development version by cloning the +`GitHub`_ repository and using the setup script:: + + git clone https://github.com/kjordahl/geopandas.git + cd geopandas python setup.py install -GeoPandas is also available on `PyPI`_, so ``pip install geopandas`` -should work as well. You will have to add the ``--pre`` flag -for pip 1.4 and later. +It is also possible to install the latest development version +available on PyPI with `pip` by adding the ``--pre`` flag for pip 1.4 +and later, or to use `pip` to install directly from the GitHub +repository with:: + + pip install git+git://github.com/kjordahl/geopandas.git + Dependencies ------------ From 353d383d873e23a453749dcdc13ef41358544443 Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Sat, 19 Apr 2014 15:28:32 -0400 Subject: [PATCH 05/21] ENH: Use sqlalchemy for PostGIS connection for better compatibility with pandas.read_sql --- geopandas/io/sql.py | 2 +- tests/util.py | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/geopandas/io/sql.py b/geopandas/io/sql.py index 1bf5d16..42b5d05 100644 --- a/geopandas/io/sql.py +++ b/geopandas/io/sql.py @@ -30,7 +30,7 @@ def read_postgis(sql, con, geom_col='geom', crs=None, index_col=None, index_col, coerce_float, params """ - df = read_sql(sql, con, index_col=index_col, coerce_float=coerce_float, + df = read_sql(sql, con.engine, index_col=index_col, coerce_float=coerce_float, params=params) if geom_col not in df: raise ValueError("Query missing geometry column '{0}'".format( diff --git a/tests/util.py b/tests/util.py index 9751c31..22940f9 100644 --- a/tests/util.py +++ b/tests/util.py @@ -1,6 +1,7 @@ import io import os.path from six.moves.urllib.request import urlopen +from sqlalchemy import create_engine from geopandas import GeoDataFrame, GeoSeries @@ -56,8 +57,11 @@ def validate_boro_df(test, df): def connect(dbname): + driver = 'psycopg2' try: - con = psycopg2.connect(dbname=dbname) + conn_str = 'postgresql+{driver}://localhost/{dbname}' + engine = create_engine(conn_str.format(driver=driver, dbname=dbname)) + con = engine.connect() except (NameError, OperationalError): return None @@ -82,8 +86,7 @@ def create_db(df): return False try: - cursor = con.cursor() - cursor.execute("DROP TABLE IF EXISTS nybb;") + con.execute("DROP TABLE IF EXISTS nybb;") sql = """CREATE TABLE nybb ( geom geometry, @@ -92,20 +95,18 @@ def create_db(df): shape_leng float, shape_area float );""" - cursor.execute(sql) + con.execute(sql) for i, row in df.iterrows(): sql = """INSERT INTO nybb VALUES ( ST_GeometryFromText(%s), %s, %s, %s, %s );""" - cursor.execute(sql, (row['geometry'].wkt, + con.execute(sql, (row['geometry'].wkt, row['BoroCode'], row['BoroName'], row['Shape_Leng'], row['Shape_Area'])) finally: - cursor.close() - con.commit() con.close() return True From 56d0fa719ac9eb71e088c3d666cbc92179c3267c Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Thu, 10 Jul 2014 23:07:45 -0500 Subject: [PATCH 06/21] ENH: Take either SQLalchemy engine or a DB API connection object --- geopandas/io/sql.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/geopandas/io/sql.py b/geopandas/io/sql.py index 42b5d05..b88f412 100644 --- a/geopandas/io/sql.py +++ b/geopandas/io/sql.py @@ -3,9 +3,9 @@ import binascii from pandas import read_sql import shapely.wkb - from geopandas import GeoSeries, GeoDataFrame + def read_postgis(sql, con, geom_col='geom', crs=None, index_col=None, coerce_float=True, params=None): """ @@ -19,7 +19,7 @@ def read_postgis(sql, con, geom_col='geom', crs=None, index_col=None, Parameters ---------- sql: string - con: DB connection object + con: DB connection object or SQLAlchemy engine geom_col: string, default 'geom' column name to convert to shapely geometries crs: optional @@ -30,8 +30,9 @@ def read_postgis(sql, con, geom_col='geom', crs=None, index_col=None, index_col, coerce_float, params """ - df = read_sql(sql, con.engine, index_col=index_col, coerce_float=coerce_float, + df = read_sql(sql, con, index_col=index_col, coerce_float=coerce_float, params=params) + if geom_col not in df: raise ValueError("Query missing geometry column '{0}'".format( geom_col)) From d57e9b101041b7259f97fc5e6d196d23140d41c5 Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Thu, 10 Jul 2014 23:08:41 -0500 Subject: [PATCH 07/21] TST: Update the tests to use SQLalchemy for new pandas and DB API for older pandas versions --- tests/test_geodataframe.py | 10 ++++++---- tests/test_io.py | 10 ++++++---- tests/util.py | 26 ++++++++++++++++++++------ 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/tests/test_geodataframe.py b/tests/test_geodataframe.py index db2b9f8..e595b49 100644 --- a/tests/test_geodataframe.py +++ b/tests/test_geodataframe.py @@ -367,8 +367,6 @@ class TestDataFrame(unittest.TestCase): {'a': 2, 'b': np.nan}]) assert_frame_equal(expected, result) - @unittest.skipIf(PANDAS_NEW_SQL_API, 'Development version of pandas ' - 'not yet supported in SQL API.') def test_from_postgis_default(self): con = connect('test_geopandas') if con is None or not create_db(self.df): @@ -378,12 +376,13 @@ class TestDataFrame(unittest.TestCase): sql = "SELECT * FROM nybb;" df = GeoDataFrame.from_postgis(sql, con) finally: + if PANDAS_NEW_SQL_API: + # It's not really a connection, it's an engine + con = con.connect() con.close() validate_boro_df(self, df) - @unittest.skipIf(PANDAS_NEW_SQL_API, 'Development version of pandas ' - 'not yet supported in SQL API.') def test_from_postgis_custom_geom_col(self): con = connect('test_geopandas') if con is None or not create_db(self.df): @@ -396,6 +395,9 @@ class TestDataFrame(unittest.TestCase): FROM nybb;""" df = GeoDataFrame.from_postgis(sql, con, geom_col='__geometry__') finally: + if PANDAS_NEW_SQL_API: + # It's not really a connection, it's an engine + con = con.connect() con.close() validate_boro_df(self, df) diff --git a/tests/test_io.py b/tests/test_io.py index 5b3eb8e..ec04bd7 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -16,8 +16,6 @@ class TestIO(unittest.TestCase): with fiona.open(path, vfs=vfs) as f: self.crs = f.crs - @unittest.skipIf(PANDAS_NEW_SQL_API, 'Development version of pandas ' - 'not yet supported in SQL API.') def test_read_postgis_default(self): con = tests.util.connect('test_geopandas') if con is None or not tests.util.create_db(self.df): @@ -27,12 +25,13 @@ class TestIO(unittest.TestCase): sql = "SELECT * FROM nybb;" df = read_postgis(sql, con) finally: + if PANDAS_NEW_SQL_API: + # It's not really a connection, it's an engine + con = con.connect() con.close() tests.util.validate_boro_df(self, df) - @unittest.skipIf(PANDAS_NEW_SQL_API, 'Development version of pandas ' - 'not yet supported in SQL API.') def test_read_postgis_custom_geom_col(self): con = tests.util.connect('test_geopandas') if con is None or not tests.util.create_db(self.df): @@ -45,6 +44,9 @@ class TestIO(unittest.TestCase): FROM nybb;""" df = read_postgis(sql, con, geom_col='__geometry__') finally: + if PANDAS_NEW_SQL_API: + # It's not really a connection, it's an engine + con = con.connect() con.close() tests.util.validate_boro_df(self, df) diff --git a/tests/util.py b/tests/util.py index 22940f9..1d80b92 100644 --- a/tests/util.py +++ b/tests/util.py @@ -5,6 +5,14 @@ from sqlalchemy import create_engine from geopandas import GeoDataFrame, GeoSeries +try: + from pandas import read_sql_table +except ImportError: + PANDAS_NEW_SQL_API = False +else: + PANDAS_NEW_SQL_API = True + + # Compatibility layer for Python 2.6: try loading unittest2 import sys if sys.version_info[:2] == (2, 6): @@ -57,16 +65,18 @@ def validate_boro_df(test, df): def connect(dbname): - driver = 'psycopg2' try: - conn_str = 'postgresql+{driver}://localhost/{dbname}' - engine = create_engine(conn_str.format(driver=driver, dbname=dbname)) - con = engine.connect() + if PANDAS_NEW_SQL_API: + driver = 'psycopg2' + conn_str = 'postgresql+{driver}://localhost/{dbname}' + engine = create_engine(conn_str.format(driver=driver, dbname=dbname)) + return engine + else: + con = psycopg2.connect(dbname=dbname) + return con except (NameError, OperationalError): return None - return con - def create_db(df): """ @@ -84,6 +94,10 @@ def create_db(df): con = connect('test_geopandas') if con is None: return False + if PANDAS_NEW_SQL_API: + con = con.connect() + else: + con = con.cursor() try: con.execute("DROP TABLE IF EXISTS nybb;") From a9746809c5549c82f202832818e0d1311fd4127f Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Thu, 10 Jul 2014 23:10:14 -0500 Subject: [PATCH 08/21] TST: Add SQLAlchemy to test requirements --- requirements.test.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.test.txt b/requirements.test.txt index a02ad28..b5b88f9 100644 --- a/requirements.test.txt +++ b/requirements.test.txt @@ -1,4 +1,5 @@ psycopg2>=2.5.1 +SQLAlchemy>=0.8.3 geopy==0.96.3 matplotlib>=1.2.1 descartes>=1.0 From f2f94c0d27786afe29d82df04eff7de27d0a690c Mon Sep 17 00:00:00 2001 From: Matthew Perry Date: Fri, 11 Jul 2014 14:34:31 -0500 Subject: [PATCH 09/21] preliminary geo interface for geodataframes --- geopandas/geodataframe.py | 35 ++++++++++++++++++++++++++++++----- tests/test_geodataframe.py | 6 ++++++ 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/geopandas/geodataframe.py b/geopandas/geodataframe.py index a3809ec..8976aab 100644 --- a/geopandas/geodataframe.py +++ b/geopandas/geodataframe.py @@ -202,7 +202,7 @@ class GeoDataFrame(GeoPandasBase, DataFrame): def to_json(self, na='null', **kwargs): - """Returns a GeoJSON representation of the GeoDataFrame. + """Returns a GeoJSON string representation of the GeoDataFrame. Parameters ---------- @@ -216,6 +216,33 @@ class GeoDataFrame(GeoPandasBase, DataFrame): The remaining *kwargs* are passed to json.dumps(). """ + return json.dumps(self._to_geo(na), **kwargs) + + @property + def __geo_interface__(self): + """Returns a python feature collection (i.e. the geointerface) + representation of the GeoDataFrame. + + This differs from `_to_geo()` only in that it is a property + with a default `na` arg instead of a method + """ + return self._to_geo(na='null') + + def _to_geo(self, na='null'): + """Returns a python feature collection (i.e. the geointerface) + representation of the GeoDataFrame. + + Parameters + ---------- + na : {'null', 'drop', 'keep'}, default 'null' + Indicates how to output missing (NaN) values in the GeoDataFrame + * null: ouput the missing entries as JSON null + * drop: remove the property from the feature. This applies to + each feature individually so that features may have + different properties + * keep: output the missing entries as NaN + """ + def fill_none(row): """ Takes in a Series, converts to a dictionary with null values @@ -246,10 +273,8 @@ class GeoDataFrame(GeoPandasBase, DataFrame): dict((k, v) for k, v in iteritems(row) if k != self._geometry_column_name), 'geometry': mapping(row[self._geometry_column_name]) } - return json.dumps( - {'type': 'FeatureCollection', - 'features': [feature(i, row) for i, row in self.iterrows()]}, - **kwargs ) + return {'type': 'FeatureCollection', + 'features': [feature(i, row) for i, row in self.iterrows()]} def to_file(self, filename, driver="ESRI Shapefile", **kwargs): """ diff --git a/tests/test_geodataframe.py b/tests/test_geodataframe.py index db2b9f8..144f239 100644 --- a/tests/test_geodataframe.py +++ b/tests/test_geodataframe.py @@ -425,3 +425,9 @@ class TestDataFrame(unittest.TestCase): with self.assertRaises(ValueError): df.set_geometry('location', inplace=True) + + def test_geodataframe_geointerface(self): + self.assertEqual(self.df.__geo_interface__['type'], 'FeatureCollection') + self.assertEqual(len(self.df.__geo_interface__['features']), + self.df.shape[0]) + From 3a743219db3f28fec4b1640ab7bf503b5a559935 Mon Sep 17 00:00:00 2001 From: Matthew Perry Date: Fri, 11 Jul 2014 15:08:28 -0500 Subject: [PATCH 10/21] geo interface for geoseries --- geopandas/geoseries.py | 7 +++++++ tests/test_geoseries.py | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/geopandas/geoseries.py b/geopandas/geoseries.py index 9ac72b7..c11850f 100644 --- a/geopandas/geoseries.py +++ b/geopandas/geoseries.py @@ -82,6 +82,13 @@ class GeoSeries(GeoPandasBase, Series): g.crs = crs return g + @property + def __geo_interface__(self): + """Returns a GeoSeries as a python feature collection + """ + from geopandas import GeoDataFrame + return GeoDataFrame({'geometry': self}).__geo_interface__ + def to_file(self, filename, driver="ESRI Shapefile", **kwargs): from geopandas import GeoDataFrame data = GeoDataFrame({"geometry": self, diff --git a/tests/test_geoseries.py b/tests/test_geoseries.py index daa21d4..e867587 100644 --- a/tests/test_geoseries.py +++ b/tests/test_geoseries.py @@ -139,5 +139,10 @@ class TestSeries(unittest.TestCase): # XXX: method works inconsistently for different pandas versions #self.na_none.fillna(method='backfill') + def test_geoseries_geointerface(self): + self.assertEqual(self.g1.__geo_interface__['type'], 'FeatureCollection') + self.assertEqual(len(self.g1.__geo_interface__['features']), + self.g1.shape[0]) + if __name__ == '__main__': unittest.main() From 196e94e1ab29b25fb2d5d665e7e38aeb7890ff16 Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Fri, 11 Jul 2014 16:11:55 -0500 Subject: [PATCH 11/21] TST CLN: Remove repeated import --- tests/util.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/util.py b/tests/util.py index 1d80b92..2c002cb 100644 --- a/tests/util.py +++ b/tests/util.py @@ -31,13 +31,6 @@ except ImportError: class OperationalError(Exception): pass -try: - from pandas import read_sql_table -except ImportError: - PANDAS_NEW_SQL_API = False -else: - PANDAS_NEW_SQL_API = True - def download_nybb(): """ Returns the path to the NYC boroughs file. Downloads if necessary. """ From 3c3518b6c9ae83d75c95bd9f1f9fe7322aaad4dd Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Sat, 12 Jul 2014 10:34:58 -0500 Subject: [PATCH 12/21] TST: Skip on OperationalError for newer pandas versions --- tests/util.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/util.py b/tests/util.py index 2c002cb..c1a0809 100644 --- a/tests/util.py +++ b/tests/util.py @@ -88,7 +88,10 @@ def create_db(df): if con is None: return False if PANDAS_NEW_SQL_API: - con = con.connect() + try: + con = con.connect() + except OperationalError: + raise unittest.case.SkipTest() else: con = con.cursor() From f84bc3892b7a18ede7adf20856ad09184e666669 Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Sat, 12 Jul 2014 11:11:41 -0500 Subject: [PATCH 13/21] TST: Don't raise in utility function --- tests/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/util.py b/tests/util.py index c1a0809..c7554d3 100644 --- a/tests/util.py +++ b/tests/util.py @@ -91,7 +91,7 @@ def create_db(df): try: con = con.connect() except OperationalError: - raise unittest.case.SkipTest() + return else: con = con.cursor() From 457e8e8b5ae0a4b6f5199a02fe435eaae0b4fcd8 Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Sat, 12 Jul 2014 13:07:54 -0500 Subject: [PATCH 14/21] TST: Don't depend on OperationalError for exceptions in connecting to test database --- tests/util.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/util.py b/tests/util.py index c7554d3..fba988b 100644 --- a/tests/util.py +++ b/tests/util.py @@ -24,13 +24,6 @@ if sys.version_info[:2] == (2, 6): else: import unittest -try: - import psycopg2 - from psycopg2 import OperationalError -except ImportError: - class OperationalError(Exception): - pass - def download_nybb(): """ Returns the path to the NYC boroughs file. Downloads if necessary. """ @@ -84,14 +77,17 @@ def create_db(df): # 'test_geopandas' and enable postgis in it: # > createdb test_geopandas # > psql -c "CREATE EXTENSION postgis" -d test_geopandas - con = connect('test_geopandas') + try: + con = connect('test_geopandas') + except: + return False if con is None: return False if PANDAS_NEW_SQL_API: try: con = con.connect() - except OperationalError: - return + except: + return False else: con = con.cursor() From 04d263ae66cc3c7c2bf9489c85e3676b080df671 Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Sat, 12 Jul 2014 13:52:22 -0500 Subject: [PATCH 15/21] TST BUG: We still need OperationalError import --- tests/util.py | 55 ++++++++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/tests/util.py b/tests/util.py index fba988b..9751c31 100644 --- a/tests/util.py +++ b/tests/util.py @@ -1,18 +1,9 @@ import io import os.path from six.moves.urllib.request import urlopen -from sqlalchemy import create_engine from geopandas import GeoDataFrame, GeoSeries -try: - from pandas import read_sql_table -except ImportError: - PANDAS_NEW_SQL_API = False -else: - PANDAS_NEW_SQL_API = True - - # Compatibility layer for Python 2.6: try loading unittest2 import sys if sys.version_info[:2] == (2, 6): @@ -24,6 +15,20 @@ if sys.version_info[:2] == (2, 6): else: import unittest +try: + import psycopg2 + from psycopg2 import OperationalError +except ImportError: + class OperationalError(Exception): + pass + +try: + from pandas import read_sql_table +except ImportError: + PANDAS_NEW_SQL_API = False +else: + PANDAS_NEW_SQL_API = True + def download_nybb(): """ Returns the path to the NYC boroughs file. Downloads if necessary. """ @@ -52,17 +57,12 @@ def validate_boro_df(test, df): def connect(dbname): try: - if PANDAS_NEW_SQL_API: - driver = 'psycopg2' - conn_str = 'postgresql+{driver}://localhost/{dbname}' - engine = create_engine(conn_str.format(driver=driver, dbname=dbname)) - return engine - else: - con = psycopg2.connect(dbname=dbname) - return con + con = psycopg2.connect(dbname=dbname) except (NameError, OperationalError): return None + return con + def create_db(df): """ @@ -77,22 +77,13 @@ def create_db(df): # 'test_geopandas' and enable postgis in it: # > createdb test_geopandas # > psql -c "CREATE EXTENSION postgis" -d test_geopandas - try: - con = connect('test_geopandas') - except: - return False + con = connect('test_geopandas') if con is None: return False - if PANDAS_NEW_SQL_API: - try: - con = con.connect() - except: - return False - else: - con = con.cursor() try: - con.execute("DROP TABLE IF EXISTS nybb;") + cursor = con.cursor() + cursor.execute("DROP TABLE IF EXISTS nybb;") sql = """CREATE TABLE nybb ( geom geometry, @@ -101,18 +92,20 @@ def create_db(df): shape_leng float, shape_area float );""" - con.execute(sql) + cursor.execute(sql) for i, row in df.iterrows(): sql = """INSERT INTO nybb VALUES ( ST_GeometryFromText(%s), %s, %s, %s, %s );""" - con.execute(sql, (row['geometry'].wkt, + cursor.execute(sql, (row['geometry'].wkt, row['BoroCode'], row['BoroName'], row['Shape_Leng'], row['Shape_Area'])) finally: + cursor.close() + con.commit() con.close() return True From db012775181a5492f267ec50e04035a41f779b57 Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Sat, 12 Jul 2014 16:08:29 -0500 Subject: [PATCH 16/21] DOC BUG: Update links to new repo name --- CONTRIBUTING.md | 2 +- README.md | 2 +- doc/source/install.rst | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fbc790f..d4330ca 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,7 +17,7 @@ In particular, when submitting a pull request: - All existing tests should pass. Please make sure that the test suite passes, both locally and on - [Travis CI](https://travis-ci.org/kjordahl/geopandas). Status on + [Travis CI](https://travis-ci.org/geopandas/geopandas). Status on Travis will be visible on a pull request. If you want to enable Travis CI on your own fork, please read the pandas guidelines link above or the diff --git a/README.md b/README.md index 5f006c1..6c2bc82 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -GeoPandas [![build status](https://secure.travis-ci.org/kjordahl/geopandas.png?branch=master)](https://travis-ci.org/kjordahl/geopandas) [![Coverage Status](https://coveralls.io/repos/kjordahl/geopandas/badge.png)](https://coveralls.io/r/kjordahl/geopandas) +GeoPandas [![build status](https://secure.travis-ci.org/geopandas/geopandas.png?branch=master)](https://travis-ci.org/geopandas/geopandas) [![Coverage Status](https://coveralls.io/repos/geopandas/geopandas/badge.png)](https://coveralls.io/r/geopandas/geopandas) ========= Python tools for geographic data diff --git a/doc/source/install.rst b/doc/source/install.rst index 3fc2467..f0be2ec 100644 --- a/doc/source/install.rst +++ b/doc/source/install.rst @@ -7,7 +7,7 @@ version, use ``pip install geopandas``. You may install the latest development version by cloning the `GitHub`_ repository and using the setup script:: - git clone https://github.com/kjordahl/geopandas.git + git clone https://github.com/geopandas/geopandas.git cd geopandas python setup.py install @@ -16,7 +16,7 @@ available on PyPI with `pip` by adding the ``--pre`` flag for pip 1.4 and later, or to use `pip` to install directly from the GitHub repository with:: - pip install git+git://github.com/kjordahl/geopandas.git + pip install git+git://github.com/geopandas/geopandas.git Dependencies @@ -51,7 +51,7 @@ Tests are automatically run on all commits on the GitHub repository, including pull requests, on `Travis CI`_. .. _PyPI: https://pypi.python.org/pypi/geopandas -.. _GitHub: https://github.com/kjordahl/geopandas +.. _GitHub: https://github.com/geopandas/geopandas .. _numpy: http://www.numpy.org .. _pandas: http://pandas.pydata.org .. _shapely: http://toblerity.github.io/shapely @@ -62,7 +62,7 @@ including pull requests, on `Travis CI`_. .. _six: https://pythonhosted.org/six .. _psycopg2: https://pypi.python.org/pypi/psycopg2 .. _pysal: http://pysal.org -.. _Travis CI: https://travis-ci.org/kjordahl/geopandas +.. _Travis CI: https://travis-ci.org/geopandas/geopandas .. toctree:: :maxdepth: 2 From 055ed0e674869d196c949e70596df288419f0a27 Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Sat, 12 Jul 2014 21:11:35 -0500 Subject: [PATCH 17/21] DOC BUG: Update supported geopy version [ci skip] --- doc/source/install.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/install.rst b/doc/source/install.rst index f0be2ec..9b3ddcc 100644 --- a/doc/source/install.rst +++ b/doc/source/install.rst @@ -29,7 +29,7 @@ Supports Python versions 2.6, 2.7, and 3.2+. - `shapely`_ - `fiona`_ - `six`_ -- `geopy`_ 0.96.3 (optional; for geocoding) +- `geopy`_ 0.99 (optional; for geocoding) - `psycopg2`_ (optional; for PostGIS connection) For plotting, these additional packages may be used: From e1da927134b4204df7d43ad8ccb0b7d59b23d77c Mon Sep 17 00:00:00 2001 From: Matthew Perry Date: Sun, 13 Jul 2014 09:07:24 -0700 Subject: [PATCH 18/21] DOC: add geo interface to user guide --- doc/source/user.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/source/user.rst b/doc/source/user.rst index e5c27e2..05c8e3c 100644 --- a/doc/source/user.rst +++ b/doc/source/user.rst @@ -254,6 +254,12 @@ Additionally, the following methods are implemented: See ``GeoSeries.bounds`` for the bounds of the geometries contained in the series. +.. attribute:: GeoSeries.__geo_interface__ + + Implements the `geo_interface`_. Returns a python data structure + to represent the ``GeoSeries`` as a GeoJSON-like ``FeatureCollection``. + Note that the features will have an empty ``properties`` dict as they don't + have associated attributes (geometry only). Methods of pandas ``Series`` objects are also available, although not all are applicable to geometric objects and some may return a @@ -312,6 +318,11 @@ Currently, the following methods are implemented for a ``GeoDataFrame``: that column, otherwise calls ``GeoSeries.plot()`` on the ``geometry`` column. Wraps the ``plot_dataframe()`` function. +.. attribute:: GeoDataFrame.__geo_interface__ + + Implements the `geo_interface`_. Returns a python data structure + to represent the ``GeoDataFrame`` as a GeoJSON-like ``FeatureCollection``. + All pandas ``DataFrame`` methods are also available, although they may not operate in a meaningful way on the ``geometry`` column and may not return a ``GeoDataFrame`` result even when it would be appropriate to @@ -480,6 +491,7 @@ borough that are in the holes: .. _matplotlib: http://matplotlib.org .. _fiona: http://toblerity.github.io/fiona .. _geopy: https://github.com/geopy/geopy +.. _geo_interface: https://gist.github.com/sgillies/2217756 .. _file containing the boroughs of New York City: http://www.nyc.gov/html/dcp/download/bytes/nybb_14aav.zip .. toctree:: From 599be2ce99535466e18604fbc21df8d2821991ab Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Sun, 13 Jul 2014 15:50:51 -0600 Subject: [PATCH 19/21] BLD: Set ISRELEASED = False --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 3f9e90d..fe309ae 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ such as PostGIS. MAJOR = 0 MINOR = 1 MICRO = 0 -ISRELEASED = True +ISRELEASED = False VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO) QUALIFIER = '' From 280e7cf4f7e667ccba796294c58edd5a0f744b70 Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Sun, 13 Jul 2014 15:52:29 -0600 Subject: [PATCH 20/21] BLD: Set default version to 0.2.0.dev-unknown --- geopandas/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geopandas/__init__.py b/geopandas/__init__.py index 9cedc51..2780f17 100644 --- a/geopandas/__init__.py +++ b/geopandas/__init__.py @@ -1,7 +1,7 @@ try: from geopandas.version import version as __version__ except ImportError: - __version__ = '0.1.0' + __version__ = '0.2.0.dev-unknown' from geopandas.geoseries import GeoSeries from geopandas.geodataframe import GeoDataFrame From ddec2d3690c937d546b1598a78fc63ad84583f72 Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Sun, 13 Jul 2014 15:53:11 -0600 Subject: [PATCH 21/21] DOC: Set version in docs --- doc/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 18d2e0b..653eb9d 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -52,7 +52,7 @@ try: version = release = d['version'] except: # FIXME: This shouldn't be hardwired, but should be set one place only - version = release = '0.1.0' + version = release = '0.2.0.dev' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages.