Add kwargs to from_file that turn on extra fiona features.

Also try to import setup from setuptools to get the 'develop'
feature.
This commit is contained in:
sgillies
2013-07-07 22:00:22 -06:00
parent eb15f97b37
commit 7782f6a00f
3 changed files with 21 additions and 4 deletions
+8 -3
View File
@@ -16,9 +16,13 @@ class GeoDataFrame(DataFrame):
self.crs = None
@classmethod
def from_file(cls, filename):
def from_file(cls, filename, **kwargs):
"""
Alternate constructor to create a GeoDataFrame from a file
Alternate constructor to create a GeoDataFrame from a file.
*filename* is either the absolute or relative path to the file to be
opened and *kwargs* are keyword args to be passed to the method when
opening the file.
Note: This method does not attempt to align rows.
Properties that are not present in all features of the source
@@ -26,7 +30,8 @@ class GeoDataFrame(DataFrame):
"""
geoms = []
columns = defaultdict(lambda: [])
with fiona.open(filename) as f:
with fiona.open(filename, **kwargs) as f:
crs = f.crs
for rec in f:
geoms.append(shape(rec['geometry']))
+4 -1
View File
@@ -1,4 +1,7 @@
from distutils.core import setup
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
setup(name='geopandas',
version='0.1dev',
+9
View File
@@ -0,0 +1,9 @@
from geopandas import GeoDataFrame
def test_from_file_():
# Data from http://www.nyc.gov/html/dcp/download/bytes/nybb_13a.zip
# saved as geopandas/examples/nybb_13a.zip.
df = GeoDataFrame.from_file(
'/nybb_13a/nybb.shp', vfs='zip://examples/nybb_13a.zip')
assert 'geometry' in df
assert len(df) == 5