0

I've basically followed the Fiona online manual verbatim to write an output file but my code crashes when I call Fiona.open() to create said output file.

Traceback reports that the reason for the crash is 'w' is not supported. How can this be?

I've assigned the source file's driver, crs, and schema into variables which are used when making the call to create an output file. I have verified that these variables are not null.

Is there something else I need to do?

NEW

This is what traceback shows:

unsupported mode: 'w'

Traceback (most recent call last):

File "/home/userid/workspace/TestScript.py", line 63, in

with fiona.open(destinationDatabaseFile, 'w', driver=source_driver, crs=source_crs, schema=source_schema) as destination:

File "/usr/lib64/python2.7/site-packages/fiona/init.py", line 176, in open

enabled_drivers=enabled_drivers, crs_wkt=crs_wkt) File "/usr/lib64/python2.7/site-packages/fiona/collection.py", line 121, in init

"unsupported mode: %r" % self.mode)

DriverError: unsupported mode: 'w'

This is my code snippet (run-time error occurs on 3rd fiona.open call):

with fiona.open(sourceDatabaseFile, 'r', layer="SomeKindaSrf") as gdb:

source_driver = gdb.driver

source_crs = gdb.crs

source_schema = gdb.schema

with fiona.open(sourceDatabaseFile, 'r', layer="AnotherKindaSrf") as gdbStructures:

   with fiona.open(destinationDatabaseFile, 'w', driver=source_driver, crs=source_crs, schema=source_schema) as destination:

       for feature in gdb:
           for buildings in gdbStructures:
  • 1
    George, I associate the word "crash" with an error that terminates the Python interpreter unexpectedly and prints no traceback. These can be pretty hard to debug. If you got a traceback, you're in luck; these are a good thing and relatively easy to debug. Without the text of the traceback, there's nothing to go on, so you must provide it when asking this kind of question. – sgillies May 24 '16 at 20:50
  • Please edit your question and provide a minimal code example and the trace back – user2856 May 25 '16 at 1:37
  • The problem might be 'under the hood' in ogr. If you don't make progress it may be worth trying the anaconda distribution's version of Fiona or checking that Fiona is finding the right paths when loading ogr – songololo May 25 '16 at 5:37
  • @sgillies and @ Luke: done! I was avoiding the codes snippet and traceback because I thought the problem was so basic to describe that it wasn't warranted. I hope the the posted information helps. – George May 25 '16 at 14:05
  • @shongololo: I will follow up with the person who installed Fiona on the computer at work. Thanks for the tip. – George May 25 '16 at 14:07
1

George, DriverError: unsupported mode: 'w' tells me that Fiona is trying to open your output GDB using OGR's read-only OpenFileGDB driver. That's OGR's (and thereby, Fiona's) default. To specify use of Esri's read-write FileGDB driver plugin (assuming that your GDAL/OGR install includes it), do this

with fiona.open(destinationDatabaseFile, 'w', driver='FileGDB', crs=source_crs, schema=source_schema) as destination: ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.