Merge pull request #24 from kjordahl/bug/df-init-crs

BUG: crs was ignored in creation of GeoDataFrame
This commit is contained in:
Kelsey Jordahl
2013-08-22 20:44:44 -07:00
2 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ class GeoDataFrame(DataFrame):
def __init__(self, *args, **kwargs):
crs = kwargs.pop('crs', None)
super(GeoDataFrame, self).__init__(*args, **kwargs)
self.crs = None
self.crs = crs
@classmethod
def from_file(cls, filename, **kwargs):
+10
View File
@@ -6,6 +6,7 @@ import shutil
import urllib2
import numpy as np
from shapely.geometry import Point
from geopandas import GeoDataFrame
@@ -13,6 +14,7 @@ from geopandas import GeoDataFrame
class TestDataFrame(unittest.TestCase):
def setUp(self):
N = 10
# Data from http://www.nyc.gov/html/dcp/download/bytes/nybb_13a.zip
# saved as geopandas/examples/nybb_13a.zip.
if not os.path.exists(os.path.join('examples', 'nybb_13a.zip')):
@@ -24,10 +26,18 @@ class TestDataFrame(unittest.TestCase):
self.tempdir = tempfile.mkdtemp()
self.boros = np.array(['Staten Island', 'Queens', 'Brooklyn',
'Manhattan', 'Bronx'])
self.crs = {'init': 'epsg:4326'}
self.df2 = GeoDataFrame([
{'geometry' : Point(x, y), 'value1': x + y, 'value2': x * y}
for x, y in zip(range(N), range(N))], crs=self.crs)
def tearDown(self):
shutil.rmtree(self.tempdir)
def test_df_init(self):
self.assertTrue(type(self.df2) is GeoDataFrame)
self.assertTrue(self.df2.crs == self.crs)
def test_from_file_(self):
self.assertTrue('geometry' in self.df)
self.assertTrue(len(self.df) == 5)