# Gis export functions not working in tauw\_legger\_tool

**URL:** <https://community.viktor.ai/t/gis-export-functions-not-working-in-tauw-legger-tool/1047>\
**Category:** Bug & Error Reports\
**Tags:** cli\
**Created:** [19 July 2023 08:09 UTC](https://community.viktor.ai/t/gis-export-functions-not-working-in-tauw-legger-tool/1047 "2023-07-19T08:09:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sjoerd.hoekstra.tauw](https://community.viktor.ai/letter_avatar_proxy/v4/letter/s/5fc32e/32.png) [@sjoerd.hoekstra.tauw](https://community.viktor.ai/u/sjoerd.hoekstra.tauw)\
**Post date:** [19 July 2023 08:09 UTC](https://community.viktor.ai/t/gis-export-functions-not-working-in-tauw-legger-tool/1047/1 "2023-07-19T08:09:12Z")

</div>

## Which tool versions are you using?

tauw\_legger\_tool

SDK: v13.6.0  
Platform: v2023.07.0  
Python: v3.10  
Isolation mode: venv

## Current Behavior

Exporting to shapefile or geopackage gives errors. Something because of fiona

## Expected Behavior

Export to shapefile or geopackage used to work. But now all the export functions have to stopped working.

## Context (optional, but preferred)

A project in the tauw\_legger\_tool has to be renewed. But the export functions have stopped working. The logging says that something is wrong with Fiona. Could it be that Fiona or Gdal have been updated recently on the viktor servers? Because I think Fiona is dependent on Gdal which might be the case.

Traceback for Geopackage:  
Traceback (most recent call last):  
File “fiona/\_shim.pyx”, line 110, in fiona.\_shim.gdal\_create  
File “fiona/\_err.pyx”, line 291, in fiona.\_err.exc\_wrap\_pointer  
fiona.\_err.CPLE\_OpenFailedError: sqlite3\_open(temp3.gpkg) failed: unable to open database file  
During handling of the above exception, another exception occurred:  
Traceback (most recent call last):  
File “viktor\_connector/connector.pyx”, line 295, in connector.Job.execute  
File “viktor/core.pyx”, line 1837, in viktor.core.\_handle\_job  
File “viktor/core.pyx”, line 1803, in viktor.core.\_handle\_job.\_handle\_button  
File “/home/user/src/app/legger\_design/controller.py”, line 203, in download\_gis\_file  
output\_file = GisExporter(driver=driver).create\_gis\_file(trajectory\_line=trajectory\_linestring,  
File “/home/user/src/app/legger\_design/gis\_exporter.py”, line 230, in create\_gis\_file  
self.\_write\_trajectory\_line(trajectory\_line, file\_name=file\_name, layer\_name=“Trajectlijn”)  
File “/home/user/src/app/legger\_design/gis\_exporter.py”, line 41, in \_write\_trajectory\_line  
with fiona.open(file\_name, ‘w’, driver=self.driver, crs=self.crs, schema=trajectory\_line\_schema,  
File “/usr/local/lib/python3.10/site-packages/fiona/env.py”, line 417, in wrapper  
return f(\*args, \*\*kwargs)  
File “/usr/local/lib/python3.10/site-packages/fiona/ **init**.py”, line 280, in open  
c = Collection(path, mode, crs=crs, driver=driver, schema=this\_schema,  
File “/usr/local/lib/python3.10/site-packages/fiona/collection.py”, line 165, in **init**  
self.session.start(self, \*\*kwargs)  
File “fiona/ogrext.pyx”, line 1010, in fiona.ogrext.WritingSession.start  
File “fiona/ogrext.pyx”, line 1011, in fiona.ogrext.WritingSession.start  
File “fiona/\_shim.pyx”, line 114, in fiona.\_shim.gdal\_create  
fiona.errors.DriverError: sqlite3\_open(temp3.gpkg) failed: unable to open database file

Traceback for shapefiles:  
Traceback (most recent call last):  
File “fiona/ogrext.pyx”, line 1133, in fiona.ogrext.WritingSession.start  
File “fiona/\_err.pyx”, line 291, in fiona.\_err.exc\_wrap\_pointer  
fiona.\_err.CPLE\_AppDefinedError: Failed to create file Trajectlijn.shp: Permission denied  
During handling of the above exception, another exception occurred:  
Traceback (most recent call last):  
File “viktor\_connector/connector.pyx”, line 295, in connector.Job.execute  
File “viktor/core.pyx”, line 1837, in viktor.core.\_handle\_job  
File “viktor/core.pyx”, line 1803, in viktor.core.\_handle\_job.\_handle\_button  
File “/home/user/src/app/legger\_design/controller.py”, line 203, in download\_gis\_file  
output\_file = GisExporter(driver=driver).create\_gis\_file(trajectory\_line=trajectory\_linestring,  
File “/home/user/src/app/legger\_design/gis\_exporter.py”, line 252, in create\_gis\_file  
self.\_write\_trajectory\_line(trajectory\_line, file\_name=f"Trajectlijn{extension}")  
File “/home/user/src/app/legger\_design/gis\_exporter.py”, line 41, in \_write\_trajectory\_line  
with fiona.open(file\_name, ‘w’, driver=self.driver, crs=self.crs, schema=trajectory\_line\_schema,  
File “/usr/local/lib/python3.10/site-packages/fiona/env.py”, line 417, in wrapper  
return f(\*args, \*\*kwargs)  
File “/usr/local/lib/python3.10/site-packages/fiona/ **init**.py”, line 280, in open  
c = Collection(path, mode, crs=crs, driver=driver, schema=this\_schema,  
File “/usr/local/lib/python3.10/site-packages/fiona/collection.py”, line 165, in **init**  
self.session.start(self, \*\*kwargs)  
File “fiona/ogrext.pyx”, line 1141, in fiona.ogrext.WritingSession.start  
fiona.errors.DriverIOError: Failed to create file Trajectlijn.shp: Permission denied

---

<div class="post-metadata">

**Author:** ![mslootweg](https://community.viktor.ai/user_avatar/community.viktor.ai/mslootweg/32/25_2.png) [@mslootweg](https://community.viktor.ai/u/mslootweg)\
**Post date:** [21 July 2023 08:03 UTC](https://community.viktor.ai/t/gis-export-functions-not-working-in-tauw-legger-tool/1047/2 "2023-07-21T08:03:59Z")

</div>

Hi Sjoerd,

Thanks for raising this. For me to check whether this is indeed a bug on our side, or some other change that may have affected your code, is it possible to provide a snippet of code from which I can work? Feel free to strip any sensitive information from the code, as long as the snippet is clear.

Also, did you obtain the traceback from your local terminal during development, or from the reported error that was sent via email when the error was reported in production?

---

<div class="post-metadata">

**Author:** ![sjoerd.hoekstra.tauw](https://community.viktor.ai/letter_avatar_proxy/v4/letter/s/5fc32e/32.png) [@sjoerd.hoekstra.tauw](https://community.viktor.ai/u/sjoerd.hoekstra.tauw)\
**Post date:** [21 July 2023 08:50 UTC](https://community.viktor.ai/t/gis-export-functions-not-working-in-tauw-legger-tool/1047/3 "2023-07-21T08:50:25Z")

</div>

Hi Marcel,

Here is the gis\_exporter script in which we use fiona. Hopefully you can find something about it.

[gis\_exporter copy.py](https://community.viktor.ai/uploads/short-url/gngMcZLU31FcL72RwHfz9LiEpDg.py) (3.2 KB)

---

<div class="post-metadata">

**Author:** ![sjoerd.hoekstra.tauw](https://community.viktor.ai/letter_avatar_proxy/v4/letter/s/5fc32e/32.png) [@sjoerd.hoekstra.tauw](https://community.viktor.ai/u/sjoerd.hoekstra.tauw)\
**Post date:** [25 July 2023 09:05 UTC](https://community.viktor.ai/t/gis-export-functions-not-working-in-tauw-legger-tool/1047/4 "2023-07-25T09:05:42Z")

</div>

@mslootweg Is it possible to read what goes wrong in the logging of the App? Maybe that gives us an idea of what is happening. Hope to hear from you soon!

---

<div class="post-metadata">

**Author:** ![mslootweg](https://community.viktor.ai/user_avatar/community.viktor.ai/mslootweg/32/25_2.png) [@mslootweg](https://community.viktor.ai/u/mslootweg)\
**Post date:** [25 July 2023 15:37 UTC](https://community.viktor.ai/t/gis-export-functions-not-working-in-tauw-legger-tool/1047/5 "2023-07-25T15:37:46Z")

</div>

Hi Sjoerd,

I have not had time yet to look at the python script you sent (thanks for that, by the way!). If you would like to inspect what is going wrong with an app in production, the platform provides the functionality of reporting a problem. When it breaks at an unexpected line in the code, a error message appears that states something in the lines of “Something went wrong”. This error is presented together with a “Report problem” button. If pressed, this will send an email to the maintainer(s) of that app. Here you as maintainer will be able to inspect the stack trace error, as well as the parameters that were used for that case.

---

<div class="post-metadata">

**Author:** ![mweehuizen](https://community.viktor.ai/user_avatar/community.viktor.ai/mweehuizen/32/17_2.png) [@mweehuizen](https://community.viktor.ai/u/mweehuizen)\
**Post date:** [28 July 2023 11:35 UTC](https://community.viktor.ai/t/gis-export-functions-not-working-in-tauw-legger-tool/1047/6 "2023-07-28T11:35:27Z")

</div>

Resolved the issue offline:

If the fiona.open() function is called with a filename (string), fiona generates files on the local disk.

it is better to handle everything in memory:

```python
def some_function(...)->File:
    output_file = File()
    with output_file.open_binary() as fp:
        with fiona.open(fp, ....) as record:
            record.write(.....)
    
    return output_file

```
