mirror of
https://github.com/wassname/geopandas.git
synced 2026-09-11 12:10:59 +08:00
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:
@@ -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']))
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user