Giter Club home page Giter Club logo

fiona's Introduction

Fiona

image

image

image

image

Fiona streams simple feature data to and from GIS formats like GeoPackage and Shapefile.

Fiona can read and write real-world data using multi-layered GIS formats, zipped and in-memory virtual file systems, from files on your hard drive or in cloud storage. This project includes Python modules and a command line interface (CLI).

Fiona depends on GDAL but is different from GDAL's own bindings. Fiona is designed to be highly productive and to make it easy to write code which is easy to read.

Installation

Fiona has several extension modules which link against libgdal. This complicates installation. Binary distributions (wheels) containing libgdal and its own dependencies are available from the Python Package Index and can be installed using pip.

pip install fiona

These wheels are mainly intended to make installation easy for simple applications, not so much for production. They are not tested for compatibility with all other binary wheels, conda packages, or QGIS, and omit many of GDAL's optional format drivers. If you need, for example, GML support you will need to build and install Fiona from a source distribution. It is possible to install Fiona from source using pip (version >= 22.3) and the --no-binary option. A specific GDAL installation can be selected by setting the GDAL_CONFIG environment variable.

pip install -U pip
pip install --no-binary fiona fiona

Many users find Anaconda and conda-forge a good way to install Fiona and get access to more optional format drivers (like GML).

Fiona 1.10 requires Python 3.8 or higher and GDAL 3.4 or higher.

Python Usage

Features are read from and written to file-like Collection objects returned from the fiona.open() function. Features are data classes modeled on the GeoJSON format. They don't have any spatial methods of their own, so if you want to transform them you will need Shapely or something like it. Here is an example of using Fiona to read some features from one data file, change their geometry attributes using Shapely, and write them to a new data file.

import fiona
from fiona import Feature, Geometry
from shapely.geometry import mapping, shape

# Open a file for reading. We'll call this the source.
with fiona.open(
    "zip+https://github.com/Toblerity/Fiona/files/11151652/coutwildrnp.zip"
) as src:

    # The file we'll write to must be initialized with a coordinate
    # system, a format driver name, and a record schema. We can get
    # initial values from the open source's profile property and then
    # modify them as we need.
    profile = src.profile
    profile["schema"]["geometry"] = "Point"
    profile["driver"] = "GPKG"

    # Open an output file, using the same format driver and coordinate
    # reference system as the source. The profile mapping fills in the
    # keyword parameters of fiona.open.
    with fiona.open("centroids.gpkg", "w", **profile) as dst:

        # Process only the feature records intersecting a box.
        for feat in src.filter(bbox=(-107.0, 37.0, -105.0, 39.0)):

            # Get the feature's centroid.
            centroid_shp = shape(feat.geometry).centroid
            new_geom = Geometry.from_dict(centroid_shp)

            # Write the feature out.
            dst.write(
                Feature(geometry=new_geom, properties=f.properties)
            )

    # The destination's contents are flushed to disk and the file is
    # closed when its with block ends. This effectively
    # executes ``dst.flush(); dst.close()``.

CLI Usage

Fiona's command line interface, named "fio", is documented at docs/cli.rst. The CLI has a number of different commands. Its fio cat command streams GeoJSON features from any dataset.

$ fio cat --compact tests/data/coutwildrnp.shp | jq -c '.'
{"geometry":{"coordinates":[[[-111.73527526855469,41.995094299316406],...]]}}
...

Documentation

For more details about this project, please see:

fiona's People

Contributors

akrherz avatar dependabot[bot] avatar ewouth avatar fcostin avatar fredj avatar geowurster avatar groutr avatar hroncok avatar ian-r-rose avatar johanvdw avatar jorisvandenbossche avatar jwass avatar lgolston avatar loicdtx avatar lordi avatar micahcochran avatar mweisman avatar mwtoews avatar perrygeo avatar qulogic avatar rbuffat avatar sebastic avatar sgillies avatar sid-kap avatar smnorris avatar snorfalorpagus avatar snowman2 avatar stefanbrand avatar timtroendle avatar youngpm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fiona's Issues

Can't define width of columns

Shapefiles default to 80 characters wide if not explicitly defined as wider. String column types have the ability to be set to 254 characters. Is there a way in Fiona to define the width of a column when writing to a shapefile?

I see the following line in the ograpi.pxd file:
void OGR_Fld_Set (void *fielddefn, char *name, int fieldtype, int width, int precision, int justification)
Yet I don't see it called anywhere else. I suspect that the width variable there allows for the definition of wider shapefile columns.

error on reading feature with Null geometry

offending file: http://cl.ly/1F2f2X1J073E

coll = collection('rus_adm0.shp', 'r')
[f['geometry'] for f in coll]
Traceback (most recent call last):
File "", line 1, in
File "ogrext.pyx", line 848, in fiona.ogrext.Iterator.next (src/fiona/ogrext.c:14008)
File "ogrext.pyx", line 446, in fiona.ogrext.FeatureBuilder.build (src/fiona/ogrext.c:7923)
ValueError: Null geometry

Deal with Shapefile format's conflation of x and multi-x geometry types

See http://www.gdal.org/ogr/drv_shapefile.html:

Note that when reading a Shapefile of type SHPT_ARC, the corresponding layer will be reported as of type
wkbLineString, but depending on the number of parts of each geometry, the actual type of the geometry for each
feature can be either OGRLineString or OGRMultiLineString. The same applies for SHPT_POLYGON shapefiles,
reported as layers of type wkbPolygon, but depending on the number of parts of each geometry, the actual type
can be either OGRPolygon or OGRMultiPolygon.

When reading from a "polygon" type shapefile, you might get polygons or multi-polygon features. TBD: whether to coerce geometries or just relax the single-type constraint in Fiona for just the Shapefile format.

Reported by @thesteve0.

Fiona Import Error

Windows, Python 2.7, ..?

ImportError: cannot import name string_types

Traceback (most recent call last):
File "E:\p\pythonlib\learn\gdaltest.py", line 9, in
import fiona
File "..\lib\fiona__init__.py", line 69, in
from six import string_types
ImportError: cannot import name string_types

python setup.py install fails to install Fiona 0.12

Package A's setup.py contains Fiona in "install_requires"

cd /path/to/A
python setup.py install

Fails with:

Searching for fiona
Reading http://pypi.python.org/simple/fiona/
Reading http://github.com/Toblerity/Fiona
Reading http://github.com/sgillies/fiona
Best match: Fiona 0.12
Downloading http://pypi.python.org/packages/source/F/Fiona/Fiona-0.12.tar.gz#md5=e91c0f9702366f49be50cb7cba4ec029
Processing Fiona-0.12.tar.gz
Running Fiona-0.12/setup.py -q bdist_egg --dist-dir /var/folders/zt/j6blp64j68b8bxffh7ynxwkm0000gq/T/easy_install-A20jd0/Fiona-0.12/egg-dist-tmp-6n2wlk
error: README.rst: No such file or directory

ValueError: Null layer error on geojson?

playing with some osm extracts.

converted shapefile to geojson
ogr2ogr -f GeoJSON paris-lines.json paris.osm-line.shp
copied to: http://dump.twofishes.net/paris-lines.json

blackmad@ns4005169:~/sites/the-neighborhoods-project$ ./make-holes.py ~/osm/paris-lines.json
Traceback (most recent call last):
File "./make-holes.py", line 12, in
source = fiona.open(sys.argv[1], 'r')
File "/usr/local/lib/python2.7/dist-packages/Fiona-0.12.1-py2.7-linux-x86_64.egg/fiona/init.py", line 99, in open
c = Collection(path, mode, encoding=encoding)
File "/usr/local/lib/python2.7/dist-packages/Fiona-0.12.1-py2.7-linux-x86_64.egg/fiona/collection.py", line 92, in init
self.session.start(self)
File "ogrext.pyx", line 591, in fiona.ogrext.Session.start (src/fiona/ogrext.c:9701)
ValueError: Null layer

weirdly I'm hitting the same issue with geojson I'm constructing by hand that qgis is happy to render: http://dump.twofishes.net/paris.osm-roads.shp.json

ImportError

HI I am on ubuntu and install fiona using pip install Fiona. But when importing I get the following error

san@san-laptop:~$ ipython -c "import fiona"
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-cc872b235141> in <module>()
----> 1 import fiona

/usr/local/lib/python2.7/dist-packages/fiona/__init__.py in <module>()
 69 from six import string_types
 70 
---> 71 from fiona.collection import Collection, supported_drivers, vsi_path
 72 from fiona.odict import OrderedDict
 73 from fiona.ogrext import _listlayers, FIELD_TYPES_MAP

/usr/local/lib/python2.7/dist-packages/fiona/collection.py in <module>()
  5 import sys
  6 
----> 7 from fiona.ogrext import Iterator, Session, WritingSession
  8 from fiona.errors import DriverError, SchemaError, CRSError
  9 from six import string_types

ImportError: /usr/lib/libspatialite.so.3: undefined symbol: GEOSInterpolate

libgdal, libgdal-dev are installed using apt-get.

san@san-laptop:~$ uname -a
Linux san-laptop 3.11.0-15-generic #23-Ubuntu SMP Mon Dec 9 18:17:04 UTC        2013 x86_64 x86_64 x86_64 GNU/Linux

Thanks

fiona can't write unicode?

it seems like unicode strings aren't being correctly written out -- I see all ????? for the name in this shapefile in both dbfdump and qgis (looking at the hex of the dbf, they are definitely all question marks, it's not a read encoding issue)..

Is this related to http://lists.osgeo.org/pipermail/gdal-dev/2012-April/032393.html + http://trac.osgeo.org/gdal/wiki/rfc5_unicode ?

Is there any way to work around this?

code:

!/usr/bin/python

-- coding: utf-8 --

from shapely.geometry import Point, mapping
from fiona import collection

schema = { 'geometry': 'Point', 'properties': { 'name': 'str' } }
with collection(
"some.shp", "w", "ESRI Shapefile", schema, encoding='utf-8') as output:
point = Point(40.74, -74.0)
output.write({
'properties': {
'name': u'Москва'
},
'geometry': mapping(point)
})

qgis:
http://www.whizziwig.com/static/captured/kaLDA.png

[blackmad@wfmu tmp]$ dbfdump /tmp/some.dbf
name
??????

[blackmad@wfmu tmp]$ hexdump -C /tmp/some.dbf
00000000 03 5f 07 1a 01 00 00 00 41 00 51 00 00 00 00 00 |._......A.Q.....|
00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 57 00 00 |.............W..|
00000020 6e 61 6d 65 00 00 00 00 00 00 00 43 00 00 00 00 |name.......C....|
00000030 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |P...............|
00000040 0d 20 3f 3f 3f 3f 3f 3f 20 20 20 20 20 20 20 20 |. ?????? |

Copying a sources schema, crs and river with **ds.meta does not work

I've found the following code does not work:

#!/usr/bin/env python

"""Tool to simplify geometries in a vector file"""

import sys

import fiona

from shapely import speedups
from shapely.geometry import mapping, shape

speedups.available and speedups.enable()


def main():
    if len(sys.argv) < 3:
        print "Usage: fixgeometries <infile>"
        raise SystemExit(1)

    with fiona.open(sys.argv[1], "r") as ds:
        items = ((feature, shape(feature["geometry"])) for feature in ds)

        with fiona.open(sys.argv[2], "w", **ds.meta) as sink:
            for feature, geometry in items:
                id = feature.get("properties", {}).get("OBJECTID", None) or feature.get("id", None)

                if not geometry.is_valid:
                    print "Geometry of Feature id {0:s} is not valid. Fixing...".format(str(id))
                    geometry = geometry.buffer(0.0)

                geometry = geometry.simplify(0.01)
                if not geometry.is_valid:
                    geometry = geometry.buffer(0.0)

                feature["geometry"] = mapping(geometry)

                sink.write(feature)


if __name__ == "__main__":
    main()

The resulting output ESRI Shapefile does not
contain any of the original properties nor does the
output schema match the original.

The only way I've found that does work is to
do something like:

with fiona.open(..., "w", crs=ds.crs, driver=ds.driver, schema=ds.schema.copy()) as sink:

Is this something that can be fixed in Fiona?

Documentation tends to lead me to believe that one could and should use **ds.meta as a nice convenient way to use the input source's schema when you're doing things like cleaning up geometries in a Shapefile, etc...

OFTDate type not supported

Traceback (most recent call last):
File "test_fiona.py", line 5, in
for f in source:
File "ogrext.pyx", line 667, in fiona.ogrext.Iterator.next (src/fiona/ogrext.c:10212)
File "ogrext.pyx", line 367, in fiona.ogrext.FeatureBuilder.build (src/fiona/ogrext.c:6325)
ValueError: Invalid field type 9

error when reading schema

from fiona import collection
collection('chl_adm0.shp', 'r').schema
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/fiona/collection.py", line 84, in schema
self._schema = self.session.get_schema()
File "ogrext.pyx", line 616, in fiona.ogrext.Session.get_schema (src/fiona/ogrext.c:10549)
IndexError: list index out of range

the offending file:
http://cl.ly/1F0b0J2A171m

works fine for other shapefiles:

collection('bra_adm0.shp', 'r').schema
{'geometry': 'Polygon', 'properties': {u'qs_adm0': 'str', u'qs_a1': 'str:254', u'qs_a2': 'str:254', u'qs_adm0_a3': 'str', u'qs_a2_lc': 'int', u'qs_level': 'str', u'qs_a1_lc': 'str:254'}}

Supporting OGR list types

Fiona's field types have names that correspond to Python types. OGR's OFTInteger becomes 'int'; OFTString, 'str'. I propose that the list types be named liked this:

OFTIntegerList: 'list:int'

OFTRealList: 'list:float'

OFTStringList: 'list:str'

Add method to get listing of layers in a file/directory.

In #45 I wrote about adding the ability to select a single layer from a directory or multi-layer file. Users will now need a method to get a listing of available layers. I propose this:

>>> import fiona
>>> fiona.listdir('docs/data/test_uk.shp')
['test_uk']

It would be to os.listdir what fiona.open is to io.open. Good? Bad? I like listdir as a name but would be open to listlayers instead.

Ordered Field Names

Hi there! I read through the documents to see if there is a way to return an ordered list of the field names in a schema. Currently, the schema properties are returned as a dictionary, so the field names are returned out of order. An ordered list of fields is important when testing to see if a schema matches a specification (order, field widths, etc).

Thanks!
Dennis

1.0 release

This is an announcement that I'd like to ship Fiona 1.0 soon and a last call for feature requests. I've just added a dumpgj script which does a bit of both ogrinfo and ogr2ogr and serves as the canonical usage example. I'm going to tweak it a little more before 1.0, finalize some args and options, possibly add some JSON-LD context information, add CRS to the GeoJSON output.

Anything else?

1.0 sdist

Tag and upload the 1.0 release to PyPI.

Runtime dynlib error on Mac OSX 10.6

I had trouble installing Fiona on Mac OSX 10.6.8. Errors were like this:

   Traceback (most recent call last):
     File "io.py", line 2, in <module>
     import fiona
       File "/Library/Python/2.6/site-packages/fiona/__init__.py", line 71, in <module>
        from fiona.collection import Collection, supported_drivers, vsi_path
       File "/Library/Python/2.6/site-packages/fiona/collection.py", line 7, in <module>
          from fiona.ogrext import Iterator, Session, WritingSession
             ImportError: dlopen(/Library/Python/2.6/site-packages/fiona/ogrext.so, 2):            
         Symbol not found: _CPLSetThreadLocalConfigOption
       Referenced from: /Library/Python/2.6/site-packages/fiona/ogrext.so
       Expected in: flat namespace
        in /Library/Python/2.6/site-packages/fiona/ogrext.so

I had GDAL 1.9.2 installed via KyngChaos. GDAL Python bindings are ok, also for other progs. I tried installing Fiona in several ways: via pip, from GIT via setup.py. Always the same runtime error.

Basically the GDAL dyn library is not found at runtime. I saw a suggestion http://sgillies.net/blog/1175/fiona-0-12 to set DYLD_LIBRARY_PATH, but whatever variant I tried: always the same error on the first "import fiona". btw DYLD_LIBRARY_PATH should be a colon-separated series of dirs, not a library itself.

otool, nm, and file commands told me that the symbols were defined and both ogrext.so and GDAL dynlib were multi-arch.

Spent several hours, looking if my system was somehow contaminated with old GDAL versions etc. Found some in /usr/local/lib, removed them, restarted but still the error (probably I should reload. Finally I found in the Mac OSX Manual other ways of enforcing a specific dyn library using

export DYLD_INSERT_LIBRARIES=/Library/Frameworks/GDAL.framework/Versions/Current/GDAL (GDAL is the dynlib itself on Mac OSX, not a directory) it worked!

Fiona is a great toolkit, I see several uses. Installing on Ubuntu Linux was a breeze. If others don't have similar problems on Mac OSX then it must be my unique config assembled over the last few years....

Read-write access to data on disk

Currently, Fiona supports read ("r"), write ("w"), and append ("a") modes in the same manner as Python's file object does. How important is "r+" access to you? If we were to add it, it would probably be done in the Python file manner again:

with collection("/path/to/data.shp", "r+") as c:
c.seek_feature(10)
c.write({...})

Unsorted arguments against:

A lot of OGR format drivers don't support random access anyway and have to fake it. I haven't been able to find a breakdown of which do and which don't. When they do have to fake it, it seems like any benefits of "r+" access are lost.

Append support for MultiPolygons in shapefiles

Shapefiles have no type MultiPolygon, but they support them anyway (all rings are stored in one polygon). See: http://www.gdal.org/ogr/drv_shapefile.html

Fiona/OGR handles everything right when I create a new Shapefile with geometry type MultiPolygon, but when I open it for appending the type changes to Polygon. Fiona will then refuse to write additional MultiPolygons (see WritingSession.writerecs).

How should we handle that? Ignore the Multi prefix when checking the geometry type for 'ESRI Shapefile' drivers?

Writing null geometries?

Unless I am missing something (dug though the code, issues, mailing lists) fiona doesn't seem to support writing null geometries. It does however support reading null geometries and returns {"geometry": None} as you'd expect. Trying to do this the other way fails.

Segmentation fault when using Fiona in the QGIS Python console

Currently when you try to write a shapefile using Fiona from the Python console in QGIS, you get a segmentation fault:

>>> c = fiona.open('foo.shp','w',driver='ESRI Shapefile',crs={},schema={'geometry':'LineString','properties':{}})
>>> cs = [(1.0,2.0),(45.0,32.0),(-10.2,39.1)]
>>> rec = {'geometry':{'type':'LineString','coordinates':cs},'properties':{}}
>>> c.write(cs)

Similar results occur when using Fiona within QGIS plugins. I know QGIS uses OGR internally, so perhaps there is not a way to get Fiona's OGR and QGIS's OGR to play nicely with each other, but I am not familiar enough with this sort of thing to know.

Here's the Apple backtrace from the QGIS crash:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   org.gdal.gdal                   0x0000000118ccce14 OGRFeatureDefn::Release() + 54
1   ogrext.so                       0x00000001187b59f8 __pyx_pw_5fiona_6ogrext_14WritingSession_3writerecs + 3208 (ogrext.c:9592)
2   org.python.python               0x000000011522f5a9 PyEval_EvalFrameEx + 9244
3   org.python.python               0x0000000115233869 0x115216000 + 120937
4   org.python.python               0x000000011522f63a PyEval_EvalFrameEx + 9389
5   org.python.python               0x0000000115233869 0x115216000 + 120937
6   org.python.python               0x000000011522f63a PyEval_EvalFrameEx + 9389
7   org.python.python               0x000000011522d147 PyEval_EvalCodeEx + 1934
8   org.python.python               0x000000011522fb3e PyEval_EvalFrameEx + 10673
9   org.python.python               0x000000011522d147 PyEval_EvalCodeEx + 1934
10  org.python.python               0x00000001152338df 0x115216000 + 121055
11  org.python.python               0x000000011522f63a PyEval_EvalFrameEx + 9389
12  org.python.python               0x000000011522d147 PyEval_EvalCodeEx + 1934
13  org.python.python               0x00000001152338df 0x115216000 + 121055
14  org.python.python               0x000000011522f63a PyEval_EvalFrameEx + 9389
15  org.python.python               0x0000000115233869 0x115216000 + 120937
16  org.python.python               0x000000011522f63a PyEval_EvalFrameEx + 9389
17  org.python.python               0x0000000115233869 0x115216000 + 120937
18  org.python.python               0x000000011522f63a PyEval_EvalFrameEx + 9389
19  org.python.python               0x000000011522d147 PyEval_EvalCodeEx + 1934
20  org.python.python               0x0000000115266d7a 0x115216000 + 331130
21  org.python.python               0x00000001152256c6 PyObject_Call + 97
22  org.python.python               0x00000001152429bf 0x115216000 + 182719
23  org.python.python               0x00000001152256c6 PyObject_Call + 97
24  org.python.python               0x0000000115233018 PyEval_CallObjectWithKeywords + 177
25  sip.so                          0x00000001154bc706 sip_api_call_method + 186
26  QtGui.so                        0x000000011590fdb0 sipVH_QtGui_25(PyGILState_STATE, _object*, QKeyEvent*) + 64
27  QtGui.so                        0x00000001159bc08d sipQTextEdit::keyPressEvent(QKeyEvent*) + 99
28  QtGui                           0x0000000104d436cb QWidget::event(QEvent*) + 2491
29  QtGui                           0x00000001050d623c QFrame::event(QEvent*) + 44
30  QtGui                           0x000000010516365b QAbstractScrollArea::event(QEvent*) + 123
31  QtGui                           0x000000010514e98b QTextEdit::event(QEvent*) + 91
32  QtGui.so                        0x00000001159b919c sipQTextEdit::event(QEvent*) + 76
33  QtGui                           0x0000000104ceb93d QApplicationPrivate::notify_helper(QObject*, QEvent*) + 189
34  QtGui                           0x0000000104cf403b QApplication::notify(QObject*, QEvent*) + 9883
35  org.qgis.qgis_core              0x0000000103d84762 QgsApplication::notify(QObject*, QEvent*) + 100
36  QtCore                          0x0000000104a3417c QCoreApplication::notifyInternal(QObject*, QEvent*) + 124
37  QtGui                           0x0000000104cebb4c qt_sendSpontaneousEvent(QObject*, QEvent*) + 44
38  QtGui                           0x0000000104d67fe1 QKeyMapper::sendKeyEvent(QWidget*, bool, QEvent::Type, int, QFlags<Qt::KeyboardModifier>, QString const&, bool, int, unsigned int, unsigned int, unsigned int, bool*) + 225
39  QtGui                           0x0000000104d68ea3 QKeyMapperPrivate::translateKeyEvent(QWidget*, OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*, bool) + 659
40  QtGui                           0x0000000104c9dadf qt_dispatchKeyEvent(void*, QWidget*) + 223
41  QtGui                           0x0000000104c8fe3f -[QCocoaView keyDown:] + 127
42  com.apple.AppKit                0x00007fff87491050 -[NSWindow sendEvent:] + 9687
43  QtGui                           0x0000000104c94a37 -[QCocoaWindow sendEvent:] + 87
44  com.apple.AppKit                0x00007fff8748c674 -[NSApplication sendEvent:] + 5761
45  QtGui                           0x0000000104c99b24 -[QNSApplication sendEvent:] + 84
46  com.apple.AppKit                0x00007fff873a224a -[NSApplication run] + 636
47  QtGui                           0x0000000104ca4900 QEventDispatcherMac::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 1824
48  QtCore                          0x0000000104a33094 QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 68
49  QtCore                          0x0000000104a33444 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 324
50  QtCore                          0x0000000104a35b2c QCoreApplication::exec() + 188
51  org.qgis.qgis                   0x000000010000996b main + 10523
52  org.qgis.qgis                   0x0000000100006c04 start + 52

Single layer vs multilayer sources

Presently, Fiona can only support single layer collections. It's difficult to understand from the OGR docs which drivers are always multilayer, which are always single-layer, and which can be both. The listing at the end of fiona/init.py is my attempt to enumerate the drivers that are or can be sources of single stand-alone layers. It's possible that there are some errors in there.

How will this list be used? When attempting to read data, we will assert that the driver chosen by OGR is in the list. When attempting to write data we will assert that the driver chosen by the programmer is in the list.

Dear potential Fiona users, how important are the multi-layer formats to you?

Missing files for running tests

In a fresh checkout of the source code, several files required to run tests do not exist. The files test_uk.zip, test_uk.tar and test_uk.json are missing, and there doesn't seem to be a standard way to create them. I created them from the included files in the docs/data directory, with some trial and error. I'm still failing one test that depends on test_uk.tar, and it's not immediately obvious whether it is because I've created that file incorrectly or for some other reason.

Should these files either be explicitly included or created easily from the included test data?

Cannot compile from source despite Cython being available

I can't seem to build Fiona from source (this repo) despite having Cuthon installed and in the path.

[webapps@ccav ~]$ workon dev
(dev)[webapps@ccav ~]$ cd
(dev)[webapps@ccav ~]$ cd work/Fiona/
(dev)[webapps@ccav Fiona]$ python setup.py develop
running develop
running egg_info
writing requirements to src/Fiona.egg-info/requires.txt
writing src/Fiona.egg-info/PKG-INFO
writing top-level names to src/Fiona.egg-info/top_level.txt
writing dependency_links to src/Fiona.egg-info/dependency_links.txt
reading manifest file 'src/Fiona.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching '*.zip' found under directory 'docs/data'
warning: no previously-included files matching '*.tar' found under directory 'docs/data'
warning: no previously-included files matching '*.json' found under directory 'docs/data'
warning: no previously-included files matching '*' found under directory 'docs/data/testing'
warning: no previously-included files matching '*' found under directory 'docs/_build'
warning: no files found matching '*.txt' under directory 'tests'
writing manifest file 'src/Fiona.egg-info/SOURCES.txt'
running build_ext
building 'fiona.ogrinit' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include -I/usr/local/include/python2.7 -c src/fiona/ogrinit.c -o build/temp.linux-x86_64-2.7/src/fiona/ogrinit.o
gcc: src/fiona/ogrinit.c: No such file or directory
gcc: no input files
error: command 'gcc' failed with exit status 1
(dev)[webapps@ccav Fiona]$ 

VERSION.txt?

It looks like VERSION.txt hasn't been updated since the 0.5 release, the current version number seems to be managed in src/fiona/init.py. Perhaps this file can either a) be removed or b) be automatically updated via the build process to sync with the correct version?

wkbLineString not supported

Traceback (most recent call last):
File "test_fiona.py", line 5, in
for f in source:
File "ogrext.pyx", line 667, in fiona.ogrext.Iterator.next (src/fiona/ogrext.c:10212)
File "ogrext.pyx", line 383, in fiona.ogrext.FeatureBuilder.build (src/fiona/ogrext.c:6503)
File "ogrext.pyx", line 173, in fiona.ogrext.GeomBuilder.build (src/fiona/ogrext.c:3263)
IndexError: list index out of range

writing a custom CRS to GeoJson

Fiona Version: 1.0.2
Python Version: 2.7.3

Is it possible to write GeoJSON records having a non-EPSG 4326 CRS?

This is the metadata of the collection I am writing:

fiona_object.meta
{'crs': {'a': 6370997, 'lon_0': -100, 'y_0': 0, 'no_defs': True, 'proj': 'laea', 'x_0': 0, 'units': 'm', 'b': 6370997, 'lat_0': 45},
 'driver': 'GeoJSON',
 'schema': {'geometry': 'MultiPolygon', 'properties': OrderedDict([('DID', 'int'), ('VID', 'int'), ('UGID', 'int'), ('TID', 'int'), ('LID', 'int'), ('GID', 'int'), ('VARIABLE', 'str'), ('ALIAS', 'str'), ('TIME', 'datetime'), ('YEAR', 'int'), ('MONTH', 'int'), ('DAY', 'int'), ('LEVEL', 'int'), ('VALUE', 'float')])}}

After closing a reopening the collection, the metadata is:

{'crs': {u'no_defs': True, u'datum': u'WGS84', u'proj': u'longlat'},
 'driver': u'GeoJSON',
 'schema': {'geometry': 'MultiPolygon', 'properties': OrderedDict([(u'DID', 'int'), (u'VID', 'int'), (u'UGID', 'int'), (u'TID', 'int'), (u'LID', 'int'), (u'GID', 'int'), (u'VARIABLE', 'str'), (u'ALIAS', 'str'), (u'TIME', 'str'), (u'YEAR', 'int'), (u'MONTH', 'int'), (u'DAY', 'int'), (u'LEVEL', 'int'), (u'VALUE', 'float')])}}

Thanks!

KML support

Support for reading from KML.

I note that KML is explicitly commented out as one of the supported import formats (https://github.com/Toblerity/Fiona/blob/master/src/fiona/__init__.py#L173). Could support be added just by allowing this?

Feel free to close as a wontfix but I'd be interested to understand why KML is not supported (and what are your recommended alternatives for converting e.g. KML => GeoJSON).

``filter`` requires re-opening the shapefile

I've noticed in code (even in fiona-0.16) that I have to re-open the Shapefile every time I call the filter function. Is this by design or a bug or something out of fiona's control wrt OGR?

Install woes: mach-o, but wrong architecture

I swear I've installed Fiona fine before, but on this Mac OS 10.6 with Python 2.7 box it's giving me the following error. Suggestion?

Aside: Shapely installs and imports just fine (from src).

import fiona
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/site-packages/fiona/init.py", line 69, in
from fiona.collection import Collection, supported_drivers
File "/usr/local/lib/python2.7/site-packages/fiona/collection.py", line 6, in
from fiona.ogrext import Iterator, Session, WritingSession
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/fiona/ogrext.so, 2): no suitable image found. Did find:
/usr/local/lib/python2.7/site-packages/fiona/ogrext.so: mach-o, but wrong architecture

Installation issue

pip install Fiona gave me:

fatal error: 'cpl_error.h' file not found

This was because gdal was not installed (fixed with homebrew brew install gdal)

You might want to add this solution to the documentation. It already says you need gdal, but knowing how to install it could help people.

Thanks!

error on reading feature with Null geometry

offending file: http://cl.ly/1F2f2X1J073E

coll = collection('rus_adm0.shp', 'r')
[f['geometry'] for f in coll]
Traceback (most recent call last):
File "", line 1, in
File "ogrext.pyx", line 848, in fiona.ogrext.Iterator.next (src/fiona/ogrext.c:14008)
File "ogrext.pyx", line 446, in fiona.ogrext.FeatureBuilder.build (src/fiona/ogrext.c:7923)
ValueError: Null geometry

Defining Numeric Field Widths

A great feature would be to define or read the width of numeric fields.

For example, specify an integer field in a dbf to be 10 digits wide or a double or float field to be a width of 12 digits and 6 decimals.

Thanks!
Dennis

Fix error: List index is out or range

$ shputils/dissolve-shapes.py -i che_adm0.shp -o che_adm0.shp -f qs_adm0_a3,qs_adm0,qs_level,qs_a0
Traceback (most recent call last):
File "shputils/dissolve-shapes.py", line 91, in
processInput()
File "shputils/dissolve-shapes.py", line 49, in processInput
matchingFields = [getActualProperty(input, f) for f in options.fields.split(',')]
File "/home/nate/public_html/dissolvers/shputils/merge_utils.py", line 28, in getActualProperty
originalSchema = collection.schema
File "/usr/local/lib/python2.6/dist-packages/fiona/collection.py", line 84, in schema
self._schema = self.session.get_schema()
File "ogrext.pyx", line 616, in fiona.ogrext.Session.get_schema (src/fiona/ogrext.c:10549)
IndexError: list index out of range

Seems to fail on unicode file paths

When I run this script ...

#!/usr/bin/python
# -*- coding: utf-8 -*-

import fiona

path1 = "test_data/english/test_uk.shp"
path2 = "test_data/español/test_uk.shp"

with fiona.open(path1, 'r') as source:
    print source.bounds

with fiona.open(path2, 'r') as source:
    print source.bounds

.. I get this output:

(-8.621389, 49.911659, 1.749444, 60.844444)
Traceback (most recent call last):
  File "fionaFail.py", line 12, in <module>
    with fiona.open(path2, 'r') as source:
  File "/Users/bgolder/projects/aavs/lib/python2.7/site-packages/fiona/__init__.py", line 123, in open
    encoding=encoding, layer=layer, vsi=vsi, archive=archive)
  File "/Users/bgolder/projects/aavs/lib/python2.7/site-packages/fiona/collection.py", line 113, in __init__
    self.session.start(self)
  File "ogrext.pyx", line 588, in fiona.ogrext.Session.start (src/fiona/ogrext.c:9975)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcc in position 15: ordinal not in range(128)

If I designate encoding, it doesn't seem to help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.