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:
-
1George, 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– sgillies2016年05月24日 20:50:34 +00:00Commented May 24, 2016 at 20:50
-
Please edit your question and provide a minimal code example and the trace backuser2856– user28562016年05月25日 01:37:25 +00:00Commented May 25, 2016 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 ogrsongololo– songololo2016年05月25日 05:37:00 +00:00Commented May 25, 2016 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– George2016年05月25日 14:05:17 +00:00Commented May 25, 2016 at 14:05
-
@shongololo: I will follow up with the person who installed Fiona on the computer at work. Thanks for the tip.George– George2016年05月25日 14:07:22 +00:00Commented May 25, 2016 at 14:07
1 Answer 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: ...
-
I just tried what you said and my script terminates with a Null driver exception. I will see if I can tell the person who installed Fiona to include Esri's read-write FileGDB driver plugin. Where is the best place to get this plugin?George– George2016年05月25日 18:01:35 +00:00Commented May 25, 2016 at 18:01
-
1According to lfd.uci.edu/~gohlke/pythonlibs/#gdal you can get the download at esri.com/apps/products/download/#File_Geodatabase_API_1.3.sgillies– sgillies2016年05月25日 20:44:51 +00:00Commented May 25, 2016 at 20:44