Repository: r5py/r5py (language: python)

Issue:
Setting/Argument for java.io.tmpdir with r5py
**Is your feature request related to a problem? Please describe.**

I tried using r5py to calculate TCMs between census tracts in the US, but get this error because R5 doesn't seem to respect the tmpdir I've set in a few places and I didn't see a mention of tmpdir in the docs:

```
Picked up _JAVA_OPTIONS: -Djava.io.tmpdir=/data/cigi/scratch/cigi-gisolve
WARNING: JNI local refs: 47, exceeds capacity: 46
Traceback (most recent call last):
  File "Thread.java", line 829, in java.lang.Thread.run
java.io.java.io.IOException: java.io.IOException: No space left on device

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "Thread.java", line 829, in java.lang.Thread.run
java.io.java.io.IOError: java.io.IOError: java.io.IOException: No space left on device

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "OSM.java", line 208, in com.conveyal.osmlib.OSM.readFromFile
java.lang.java.lang.RuntimeException: java.lang.RuntimeException: Writer thread failed

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "OSM.java", line 210, in com.conveyal.osmlib.OSM.readFromFile
Exception: Java Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/data/keeling/a/cigi-gisolve/usr5pytest/r5py4us.py", line 16, in <module>
    transport_network = r5py.TransportNetwork(
                        ^^^^^^^^^^^^^^^^^^^^^^
  File "/data/keeling/a/cigi-gisolve/miniconda3/envs/geo/lib/python3.11/site-packages/r5py/r5/transport_network.py", line 60, in __init__
    osm_file.readFromFile(f"{osm_pbf}")
java.lang.java.lang.RuntimeException: java.lang.RuntimeException: Error occurred while parsing OSM file /tmp/r5pyv5q3s6tt/TransportNetwork_2affd5d80190_0081957/us-latest.osm.pbf
Exception ignored in: <function TransportNetwork.__del__ at 0x2b32910322a0>
Traceback (most recent call last):
  File "/data/keeling/a/cigi-gisolve/miniconda3/envs/geo/lib/python3.11/site-packages/r5py/r5/transport_network.py", line 98, in __del__
    self.osm_file.close()
    ^^^^^^^^^^^^^
AttributeError: 'TransportNetwork' object has no attribute 'osm_file'
```

It still uses /tmp as you can see in the error stacktrace. 

**Describe the solution you'd like**

Some setting, environmental variable, or argument to set the Java tmpdir such that R5 listens.

**Describe alternatives you've considered**

I've exported the environmental variable in the SBATCH script as well as the ~/.bashrc and ~/.profile, but it appears that R5 still uses /tmp regardless of how I set it.

**Additional context**

Here are the necessary scripts to reproduce:

## Get The Data

OSM data (Bash):

```
mkdir -p data/
cd data/
wget https://download.geofabrik.de/north-america/us-latest.osm.pbf
md5sum us-latest.osm.pbf  # check the hash
```

US Census Tracts (python):

```
import geopandas as gpd
import os
import pandas as pd
import pathlib
import urllib.request
from us import states
import zipfile

download_path = "./data/pop/"

pathlib.Path(download_path).mkdir(parents=True, exist_ok=True)

# URL for the file minus the state FIPS code
base_url = "https://www2.census.gov/geo/tiger/TIGER2020/TRACT/tl_2020_{}_tract.zip"
# file to save to minus the state FIPS code
base_file = "tl_2020_{}_tract.zip"
unzip_file = "tl_2020_{}_tract.shp"

# get list of contiguous US
contiguous_states = [state for state in states.STATES if state.is_contiguous]
# add in DC:
contiguous_states.append(states.DC)

# download data
for state in contiguous_states:
    state_url = base_url.format(state.fips)
    state_file = os.path.join(download_path, base_file.format(state.fips))
    urllib.request.urlretrieve(state_url, state_file)
    # unzip it
    with zipfile.ZipFile(state_file, "r") as zip_ref:
        zip_ref.extractall(download_path)


# concat them all into one
geodataframes = []
for state in contiguous_states:
    gdf = gpd.read_file(os.path.join(download_path, unzip_file.format(state.fips)))
    geodataframes.append(gdf)

contiguous_gdf = gpd.GeoDataFrame(pd.concat(geodataframes, ignore_index=True))
print(len(contiguous_gdf))
contiguous_gdf.to_file(os.path.join(download_path, "USTRACT.shp"))
```

## Python Script

```
import datetime
import geopandas as gpd
import r5py
from r5py import TransportMode
import sys
import os

# load census tracts
tracts = gpd.read_file("data/pop/USTRACT.shp")
# Albers Equal Area
tracts = tracts.to_crs("ESRI:102003")
tracts["geometry"] = tracts.geometry.centroid


# set the transport network
transport_network = r5py.TransportNetwork(
    osm_pbf="data/us-latest.osm.pbf",
    gtfs=[]
)

# Initialize the tool
travel_time_matrix_computer = TravelTimeMatrixComputer(
    transport_network,
    origins=tracts,
    destinations=tracts,
    departure=datetime.datetime(2023,9,13,8,30),
    transport_modes=[TransportMode.TRANSIT, TransportMode.WALK]
)

travel_time_matrix = travel_time_matrix_computer.compute_travel_times()
print(len(trave_time_matrix))
travel_time_matrix.to_csv("traveltimes.csv")
```

# Environment Info:

<details>
<summary>Conda export (based on the conda env from OTESAMA Workshop):</summary>


```
name: geo
channels:
  - conda-forge
  - nodefaults
dependencies:
  - _libgcc_mutex=0.1=conda_forge
  - _openmp_mutex=4.5=2_gnu
  - _r-mutex=1.0.1=anacondar_1
  - access=1.1.8=pyhd8ed1ab_0
  - affine=2.4.0=pyhd8ed1ab_0
  - alsa-lib=1.2.9=hd590300_0
  - amply=0.1.6=pyhd8ed1ab_0
  - anyio=4.0.0=pyhd8ed1ab_0
  - argon2-cffi=23.1.0=pyhd8ed1ab_0
  - argon2-cffi-bindings=21.2.0=py311hd4cff14_3
  - arrow=1.2.3=pyhd8ed1ab_0
  - asttokens=2.4.0=pyhd8ed1ab_0
  - async-lru=2.0.4=pyhd8ed1ab_0
  - attr=2.5.1=h166bdaf_1
  - attrs=23.1.0=pyh71513ae_1
  - babel=2.12.1=pyhd8ed1ab_1
  - backcall=0.2.0=pyh9f0ad1d_0
  - backports=1.0=pyhd8ed1ab_3
  - backports.functools_lru_cache=1.6.5=pyhd8ed1ab_0
  - beautifulsoup4=4.12.2=pyha770c72_0
  - binutils_impl_linux-64=2.40=hf600244_0
  - bleach=6.0.0=pyhd8ed1ab_0
  - blosc=1.21.5=h0f2a231_0
  - boltons=23.0.0=pyhd8ed1ab_0
  - boost-cpp=1.78.0=h6582d0a_3
  - branca=0.6.0=pyhd8ed1ab_0
  - brotli=1.1.0=hd590300_0
  - brotli-bin=1.1.0=hd590300_0
  - brotli-python=1.1.0=py311hb755f60_0
  - bwidget=1.9.14=ha770c72_1
  - bzip2=1.0.8=h7f98852_4
  - c-ares=1.19.1=hd590300_0
  - ca-certificates=2023.7.22=hbcca054_0
  - cached-property=1.5.2=hd8ed1ab_1
  - cached_property=1.5.2=pyha770c72_1
  - cairo=1.16.0=hbbf8b49_1016
  - certifi=2023.7.22=pyhd8ed1ab_0
  - cffi=1.15.1=py311h409f033_3
  - cfitsio=4.3.0=hbdc6101_0
  - charset-normalizer=3.2.0=pyhd8ed1ab_0
  - click=8.1.7=unix_pyh707e725_0
  - click-plugins=1.1.1=py_0
  - cligj=0.7.2=pyhd8ed1ab_1
  - coin-or-cbc=2.10.10=h9002f0b_0
  - coin-or-cgl=0.60.7=h516709c_0
  - coin-or-clp=1.17.8=h1ee7a9c_0
  - coin-or-osi=0.108.8=ha2443b9_0
  - coin-or-utils=2.11.9=hee58242_0
  - coincbc=2.10.10=0_metapackage
  - colorama=0.4.6=pyhd8ed1ab_0
  - comm=0.1.4=pyhd8ed1ab_0
  - conda=23.7.4=py311h38be061_0
  - conda-package-handling=2.2.0=pyh38be061_0
  - conda-package-streaming=0.9.0=pyhd8ed1ab_0
  - configargparse=1.7=pyhd8ed1ab_0
  - contourpy=1.1.0=py311h9547e67_0
  - cryptography=41.0.3=py311h63ff55d_0
  - curl=8.3.0=hca28451_0
  - cycler=0.11.0=pyhd8ed1ab_0
  - dataclasses=0.8=pyhc8e2a94_3
  - dbus=1.13.6=h5008d03_3
  - debugpy=1.8.0=py311hb755f60_0
  - decorator=5.1.1=pyhd8ed1ab_0
  - defusedxml=0.7.1=pyhd8ed1ab_0
  - deprecation=2.1.0=pyh9f0ad1d_0
  - descartes=1.1.0=py_4
  - docutils=0.20.1=py311h38be061_1
  - entrypoints=0.4=pyhd8ed1ab_0
  - esda=2.5.0=pyhd8ed1ab_0
  - exceptiongroup=1.1.3=pyhd8ed1ab_0
  - executing=1.2.0=pyhd8ed1ab_0
  - expat=2.5.0=hcb278e6_1
  - filelock=3.12.4=pyhd8ed1ab_0
  - fiona=1.9.4=py311hbac4ec9_0
  - fmt=10.1.1=h00ab1b0_0
  - folium=0.14.0=pyhd8ed1ab_0
  - font-ttf-dejavu-sans-mono=2.37=hab24e00_0
  - font-ttf-inconsolata=3.000=h77eed37_0
  - font-ttf-source-code-pro=2.038=h77eed37_0
  - font-ttf-ubuntu=0.83=hab24e00_0
  - fontconfig=2.14.2=h14ed4e7_0
  - fonts-conda-ecosystem=1=0
  - fonts-conda-forge=1=0
  - fonttools=4.42.1=py311h459d7ec_0
  - fqdn=1.5.1=pyhd8ed1ab_0
  - freetype=2.12.1=h267a509_2
  - freexl=1.0.6=h166bdaf_1
  - fribidi=1.0.10=h36c2ea0_0
  - gcc_impl_linux-64=13.2.0=h338b0a0_0
  - gdal=3.7.2=py311h815a124_0
  - geographiclib=1.52=pyhd8ed1ab_0
  - geopandas=0.13.2=pyhd8ed1ab_1
  - geopandas-base=0.13.2=pyha770c72_1
  - geopy=2.4.0=pyhd8ed1ab_0
  - geos=3.12.0=h59595ed_0
  - geotiff=1.7.1=h22adcc9_11
  - gettext=0.21.1=h27087fc_0
  - gfortran_impl_linux-64=13.2.0=h76e1118_0
  - giddy=2.3.4=pyhd8ed1ab_0
  - giflib=5.2.1=h0b41bf4_3
  - gitdb=4.0.10=pyhd8ed1ab_0
  - gitpython=3.1.36=pyhd8ed1ab_0
  - glib=2.78.0=hfc55251_0
  - glib-tools=2.78.0=hfc55251_0
  - gmp=6.2.1=h58526e2_0
  - gmpy2=2.1.2=py311h6a5fa03_1
  - graphite2=1.3.13=h58526e2_1001
  - gsl=2.7=he838d99_0
  - gst-plugins-base=1.22.5=hf7dbed1_0
  - gstreamer=1.22.5=h98fc4e7_0
  - gxx_impl_linux-64=13.2.0=h338b0a0_0
  - harfbuzz=7.3.0=hdb3a94d_0
  - hdf4=4.2.15=h501b40f_6
  - hdf5=1.14.2=nompi_h4f84152_100
  - icu=72.1=hcb278e6_0
  - idna=3.4=pyhd8ed1ab_0
  - importlib-metadata=6.8.0=pyha770c72_0
  - importlib_metadata=6.8.0=hd8ed1ab_0
  - importlib_resources=6.0.1=pyhd8ed1ab_0
  - inequality=1.0.0=py_0
  - ipykernel=6.25.2=pyh2140261_0
  - ipython=8.15.0=pyh0d859eb_0
  - ipywidgets=8.1.1=pyhd8ed1ab_0
  - isoduration=20.11.0=pyhd8ed1ab_0
  - jedi=0.19.0=pyhd8ed1ab_0
  - jinja2=3.1.2=pyhd8ed1ab_1
  - joblib=1.3.2=pyhd8ed1ab_0
  - jpype1=1.4.1=py311h4dd048b_1
  - json-c=0.17=h7ab15ed_0
  - json5=0.9.14=pyhd8ed1ab_0
  - jsonpatch=1.32=pyhd8ed1ab_0
  - jsonpointer=2.4=py311h38be061_2
  - jsonschema=4.19.0=pyhd8ed1ab_1
  - jsonschema-specifications=2023.7.1=pyhd8ed1ab_0
  - jsonschema-with-format-nongpl=4.19.0=pyhd8ed1ab_1
  - jupyter-lsp=2.2.0=pyhd8ed1ab_0
  - jupyter-server-mathjax=0.2.6=pyh5bfe37b_1
  - jupyter_client=8.3.1=pyhd8ed1ab_0
  - jupyter_core=5.3.1=py311h38be061_0
  - jupyter_events=0.7.0=pyhd8ed1ab_2
  - jupyter_server=2.7.3=pyhd8ed1ab_0
  - jupyter_server_terminals=0.4.4=pyhd8ed1ab_1
  - jupyterlab=4.0.5=pyhd8ed1ab_0
  - jupyterlab-git=0.41.0=pyhd8ed1ab_1
  - jupyterlab_pygments=0.2.2=pyhd8ed1ab_0
  - jupyterlab_server=2.25.0=pyhd8ed1ab_0
  - jupyterlab_widgets=3.0.9=pyhd8ed1ab_0
  - kealib=1.5.1=hcd42e92_5
  - kernel-headers_linux-64=2.6.32=he073ed8_16
  - keyutils=1.6.1=h166bdaf_0
  - kiwisolver=1.4.5=py311h9547e67_0
  - krb5=1.21.2=h659d440_0
  - lame=3.100=h166bdaf_1003
  - lcms2=2.15=haa2dc70_1
  - ld_impl_linux-64=2.40=h41732ed_0
  - lerc=4.0.0=h27087fc_0
  - libabseil=20230802.0=cxx17_h59595ed_3
  - libaec=1.0.6=hcb278e6_1
  - libarchive=3.6.2=h039dbb9_1
  - libblas=3.9.0=18_linux64_openblas
  - libbrotlicommon=1.1.0=hd590300_0
  - libbrotlidec=1.1.0=hd590300_0
  - libbrotlienc=1.1.0=hd590300_0
  - libcap=2.69=h0f662aa_0
  - libcblas=3.9.0=18_linux64_openblas
  - libclang=15.0.7=default_h7634d5b_3
  - libclang13=15.0.7=default_h9986a30_3
  - libcrc32c=1.1.2=h9c3ff4c_0
  - libcups=2.3.3=h4637d8d_4
  - libcurl=8.3.0=hca28451_0
  - libdeflate=1.18=h0b41bf4_0
  - libedit=3.1.20191231=he28a2e2_2
  - libev=4.33=h516909a_1
  - libevent=2.1.12=hf998b51_1
  - libexpat=2.5.0=hcb278e6_1
  - libffi=3.4.2=h7f98852_5
  - libflac=1.4.3=h59595ed_0
  - libgcc-devel_linux-64=13.2.0=ha9c7c90_0
  - libgcc-ng=13.2.0=h807b86a_0
  - libgcrypt=1.10.1=h166bdaf_0
  - libgdal=3.7.2=h5b94d6b_0
  - libgfortran-ng=13.2.0=h69a702a_0
  - libgfortran5=13.2.0=ha4646dd_0
  - libgit2=1.7.1=hca3a8ce_0
  - libglib=2.78.0=hebfc3b9_0
  - libgomp=13.2.0=h807b86a_0
  - libgoogle-cloud=2.12.0=h8d7e28b_2
  - libgpg-error=1.47=h71f35ed_0
  - libgrpc=1.57.0=ha4d0f93_1
  - libiconv=1.17=h166bdaf_0
  - libjpeg-turbo=2.1.5.1=hd590300_1
  - libkml=1.3.0=h37653c0_1015
  - liblapack=3.9.0=18_linux64_openblas
  - liblapacke=3.9.0=18_linux64_openblas
  - libllvm14=14.0.6=hcd5def8_4
  - libllvm15=15.0.7=h5cf9203_3
  - libmamba=1.5.1=h744094f_0
  - libmambapy=1.5.1=py311hf2555c7_0
  - libnetcdf=4.9.2=nompi_h80fb2b6_112
  - libnghttp2=1.52.0=h61bc06f_0
  - libnsl=2.0.0=h7f98852_0
  - libogg=1.3.4=h7f98852_1
  - libopenblas=0.3.24=pthreads_h413a1c8_0
  - libopus=1.3.1=h7f98852_1
  - libpng=1.6.39=h753d276_0
  - libpq=15.4=hfc447b1_0
  - libprotobuf=4.23.4=hf27288f_6
  - libpysal=4.7.0=pyhd8ed1ab_0
  - librttopo=1.1.0=hb58d41b_14
  - libsanitizer=13.2.0=h7e041cc_0
  - libsndfile=1.2.2=hbc2eb40_0
  - libsodium=1.0.18=h36c2ea0_1
  - libsolv=0.7.24=hfc55251_4
  - libspatialindex=1.9.3=h9c3ff4c_4
  - libspatialite=5.0.1=h15f6e67_28
  - libsqlite=3.43.0=h2797004_0
  - libssh2=1.11.0=h0841786_0
  - libstdcxx-devel_linux-64=13.2.0=ha9c7c90_0
  - libstdcxx-ng=13.2.0=h7e041cc_0
  - libsystemd0=254=h3516f8a_0
  - libtiff=4.5.1=h8b53f26_1
  - libuuid=2.38.1=h0b41bf4_0
  - libv8=8.9.83=h3f08ab5_3
  - libvorbis=1.3.7=h9c3ff4c_0
  - libwebp-base=1.3.1=hd590300_0
  - libxcb=1.15=h0b41bf4_0
  - libxkbcommon=1.5.0=h5d7e998_3
  - libxml2=2.11.5=h0d562d8_0
  - libxslt=1.1.37=h0054252_1
  - libzip=1.10.1=h2629f0a_3
  - libzlib=1.2.13=hd590300_5
  - llvmlite=0.40.1=py311ha6695c7_0
  - lxml=4.9.3=py311h1a07684_0
  - lz4-c=1.9.4=hcb278e6_0
  - lzo=2.10=h516909a_1000
  - make=4.3=hd18ef5c_1
  - mamba=1.5.1=py311h3072747_0
  - mapclassify=2.5.0=pyhd8ed1ab_1
  - markupsafe=2.1.3=py311h459d7ec_0
  - matplotlib=3.7.2=py311h38be061_0
  - matplotlib-base=3.7.2=py311h54ef318_0
  - matplotlib-inline=0.1.6=pyhd8ed1ab_0
  - mgwr=2.1.2=py_0
  - mistune=3.0.1=pyhd8ed1ab_0
  - momepy=0.6.0=pyhd8ed1ab_1
  - mpc=1.3.1=hfe3b2da_0
  - mpfr=4.2.0=hb012696_0
  - mpg123=1.31.3=hcb278e6_0
  - mpmath=1.3.0=pyhd8ed1ab_0
  - munch=4.0.0=pyhd8ed1ab_0
  - munkres=1.1.4=pyh9f0ad1d_0
  - mysql-common=8.0.33=hf1915f5_4
  - mysql-libs=8.0.33=hca2cd23_4
  - nbclient=0.8.0=pyhd8ed1ab_0
  - nbconvert-core=7.8.0=pyhd8ed1ab_0
  - nbdime=3.2.1=pyhd8ed1ab_0
  - nbformat=5.9.2=pyhd8ed1ab_0
  - ncurses=6.4=hcb278e6_0
  - nest-asyncio=1.5.6=pyhd8ed1ab_0
  - networkx=3.1=pyhd8ed1ab_0
  - notebook-shim=0.2.3=pyhd8ed1ab_0
  - nspr=4.35=h27087fc_0
  - nss=3.92=h1d7d5a4_0
  - numba=0.57.1=py311h96b013e_0
  - numpy=1.24.4=py311h64a7726_0
  - openjdk=11.0.15=h8e330f5_5
  - openjpeg=2.5.0=hfec8fc6_2
  - openssl=3.1.2=hd590300_0
  - osmnx=1.6.0=pyhd8ed1ab_0
  - overrides=7.4.0=pyhd8ed1ab_0
  - owslib=0.29.2=pyhd8ed1ab_0
  - packaging=23.1=pyhd8ed1ab_0
  - pandas=2.0.3=py311h320fe9a_1
  - pandoc=3.1.3=h32600fe_0
  - pandocfilters=1.5.0=pyhd8ed1ab_0
  - pango=1.50.14=heaa33ce_1
  - parso=0.8.3=pyhd8ed1ab_0
  - patsy=0.5.3=pyhd8ed1ab_0
  - pcre2=10.40=hc3806b6_0
  - pexpect=4.8.0=pyh1a96a4e_2
  - pickleshare=0.7.5=py_1003
  - pillow=10.0.0=py311h0b84326_0
  - pip=23.2.1=pyhd8ed1ab_0
  - pixman=0.40.0=h36c2ea0_0
  - pkgutil-resolve-name=1.3.10=pyhd8ed1ab_1
  - platformdirs=3.10.0=pyhd8ed1ab_0
  - pluggy=1.3.0=pyhd8ed1ab_0
  - ply=3.11=py_1
  - pointpats=2.3.0=pyhd8ed1ab_0
  - poppler=23.08.0=hd18248d_0
  - poppler-data=0.4.12=hd8ed1ab_0
  - postgresql=15.4=h8972f4a_0
  - proj=9.2.1=ha643af7_0
  - prometheus_client=0.17.1=pyhd8ed1ab_0
  - prompt-toolkit=3.0.39=pyha770c72_0
  - prompt_toolkit=3.0.39=hd8ed1ab_0
  - psutil=5.9.5=py311h2582759_0
  - pthread-stubs=0.4=h36c2ea0_1001
  - ptyprocess=0.7.0=pyhd3deb0d_0
  - pulp=2.7.0=py311h38be061_0
  - pulseaudio-client=16.1=hb77b528_5
  - pure_eval=0.2.2=pyhd8ed1ab_0
  - pybind11-abi=4=hd8ed1ab_3
  - pycosat=0.6.4=py311hd4cff14_1
  - pycparser=2.21=pyhd8ed1ab_0
  - pygments=2.16.1=pyhd8ed1ab_0
  - pyogrio=0.6.0=py311hbac4ec9_1
  - pyopenssl=23.2.0=pyhd8ed1ab_1
  - pyparsing=3.0.9=pyhd8ed1ab_0
  - pyproj=3.6.0=py311ha169711_1
  - pyqt=5.15.9=py311hf0fb5b6_4
  - pyqt5-sip=12.12.2=py311hb755f60_4
  - pysal=23.1=pyhd8ed1ab_0
  - pysocks=1.7.1=pyha2e5f31_6
  - python=3.11.5=hab00c5b_0_cpython
  - python-dateutil=2.8.2=pyhd8ed1ab_0
  - python-fastjsonschema=2.18.0=pyhd8ed1ab_0
  - python-json-logger=2.0.7=pyhd8ed1ab_0
  - python-tzdata=2023.3=pyhd8ed1ab_0
  - python_abi=3.11=3_cp311
  - pytz=2023.3.post1=pyhd8ed1ab_0
  - pyyaml=6.0.1=py311h459d7ec_0
  - pyzmq=25.1.1=py311h75c88c4_0
  - qt-main=5.15.8=h7fe3ca9_15
  - quantecon=0.5.3=pyhd8ed1ab_0
  - r-abind=1.4_5=r43hc72bb7e_1005
  - r-askpass=1.2.0=r43h57805ef_0
  - r-assertthat=0.2.1=r43hc72bb7e_4
  - r-backports=1.4.1=r43h57805ef_2
  - r-base=4.3.1=h29c4799_3
  - r-base64enc=0.1_3=r43h57805ef_1006
  - r-brew=1.0_8=r43hc72bb7e_2
  - r-brio=1.1.3=r43h57805ef_2
  - r-bslib=0.5.1=r43hc72bb7e_0
  - r-cachem=1.0.8=r43h57805ef_1
  - r-callr=3.7.3=r43hc72bb7e_1
  - r-checkmate=2.2.0=r43h57805ef_1
  - r-class=7.3_22=r43h57805ef_1
  - r-classint=0.4_10=r43h61816a4_0
  - r-cli=3.6.1=r43ha503ecb_1
  - r-clipr=0.8.0=r43hc72bb7e_2
  - r-codetools=0.2_19=r43hc72bb7e_1
  - r-colorspace=2.1_0=r43h57805ef_1
  - r-colourvalues=0.3.9=r43ha503ecb_1
  - r-commonmark=1.9.0=r43h57805ef_1
  - r-concaveman=1.1.0=r43hc72bb7e_2
  - r-cpp11=0.4.6=r43hc72bb7e_0
  - r-crayon=1.5.2=r43hc72bb7e_2
  - r-credentials=2.0.1=r43hc72bb7e_0
  - r-crosstalk=1.2.0=r43hc72bb7e_2
  - r-crsmeta=0.3.0=r43hc72bb7e_2
  - r-curl=5.0.2=r43hf9611b0_0
  - r-data.table=1.14.8=r43h029312a_2
  - r-dbi=1.1.3=r43hc72bb7e_2
  - r-deldir=1.0_9=r43h61816a4_1
  - r-desc=1.4.2=r43hc72bb7e_2
  - r-devtools=2.4.5=r43hc72bb7e_2
  - r-dichromat=2.0_0.1=r43ha770c72_2
  - r-diffobj=0.3.5=r43h57805ef_2
  - r-digest=0.6.33=r43ha503ecb_0
  - r-downlit=0.4.3=r43hc72bb7e_0
  - r-dplyr=1.1.3=r43ha503ecb_0
  - r-e1071=1.7_13=r43ha503ecb_1
  - r-ellipsis=0.3.2=r43h57805ef_2
  - r-evaluate=0.21=r43hc72bb7e_1
  - r-fansi=1.0.4=r43h57805ef_1
  - r-farver=2.1.1=r43ha503ecb_2
  - r-fastmap=1.1.1=r43ha503ecb_1
  - r-fontawesome=0.5.2=r43hc72bb7e_0
  - r-fs=1.6.3=r43ha503ecb_0
  - r-generics=0.1.3=r43hc72bb7e_2
  - r-geojsonsf=2.0.3=r43ha503ecb_2
  - r-geometries=0.2.3=r43ha503ecb_0
  - r-gert=1.9.3=r43hc25a090_1
  - r-ggplot2=3.4.3=r43hc72bb7e_0
  - r-gh=1.4.0=r43hc72bb7e_1
  - r-gitcreds=0.1.2=r43hc72bb7e_2
  - r-glue=1.6.2=r43h57805ef_2
  - r-googlepolylines=0.8.3=r43ha503ecb_1
  - r-gridextra=2.3=r43hc72bb7e_1005
  - r-gtable=0.3.4=r43hc72bb7e_0
  - r-highr=0.10=r43hc72bb7e_1
  - r-hms=1.1.3=r43hc72bb7e_1
  - r-htmltools=0.5.6=r43ha503ecb_0
  - r-htmlwidgets=1.6.2=r43hc72bb7e_1
  - r-httpuv=1.6.11=r43ha503ecb_1
  - r-httr=1.4.7=r43hc72bb7e_0
  - r-httr2=0.2.3=r43hc72bb7e_1
  - r-ini=0.3.1=r43hc72bb7e_1005
  - r-interp=1.1_4=r43hcf54a89_1
  - r-irdisplay=1.1=r43hd8ed1ab_2
  - r-irkernel=1.3.2=r43h785f33e_1
  - r-isoband=0.2.7=r43ha503ecb_2
  - r-jquerylib=0.1.4=r43hc72bb7e_2
  - r-jsonify=1.2.2=r43ha503ecb_1
  - r-jsonlite=1.8.7=r43h57805ef_0
  - r-kernsmooth=2.23_22=r43h13b3f57_0
  - r-knitr=1.44=r43hc72bb7e_0
  - r-labeling=0.4.3=r43hc72bb7e_0
  - r-later=1.3.1=r43ha503ecb_1
  - r-lattice=0.21_8=r43h57805ef_1
  - r-lazyeval=0.2.2=r43h57805ef_4
  - r-leafem=0.2.0=r43h785f33e_2
  - r-leaflet=2.2.0=r43hc72bb7e_0
  - r-leaflet.providers=1.13.0=r43hc72bb7e_0
  - r-leafpop=0.1.0=r43ha503ecb_2
  - r-leafsync=0.1.0=r43hc72bb7e_3
  - r-lifecycle=1.0.3=r43hc72bb7e_2
  - r-lubridate=1.9.2=r43h57805ef_2
  - r-lwgeom=0.2_13=r43hdf85718_3
  - r-magrittr=2.0.3=r43h57805ef_2
  - r-mapdeck=0.3.4=r43ha503ecb_3
  - r-mapview=2.11.0=r43hc72bb7e_2
  - r-markdown=1.8=r43hc72bb7e_0
  - r-mass=7.3_60=r43h57805ef_1
  - r-matrix=1.6_1=r43h316c678_0
  - r-memoise=2.0.1=r43hc72bb7e_2
  - r-mgcv=1.9_0=r43h316c678_0
  - r-mime=0.12=r43h57805ef_2
  - r-miniui=0.1.1.1=r43hc72bb7e_1004
  - r-munsell=0.5.0=r43hc72bb7e_1006
  - r-nlme=3.1_163=r43h61816a4_0
  - r-openssl=2.0.6=r43hb353fa6_1
  - r-osmdata=0.2.5=r43ha503ecb_0
  - r-patchwork=1.1.3=r43hc72bb7e_0
  - r-pbdzmq=0.3_10=r43ha81a24b_0
  - r-pillar=1.9.0=r43hc72bb7e_1
  - r-pkgbuild=1.4.2=r43hc72bb7e_0
  - r-pkgconfig=2.0.3=r43hc72bb7e_3
  - r-pkgdown=2.0.7=r43hc72bb7e_1
  - r-pkgload=1.3.2.1=r43hc72bb7e_0
  - r-plyr=1.8.8=r43ha503ecb_1
  - r-png=0.1_8=r43h81d01c5_1
  - r-praise=1.0.0=r43hc72bb7e_1007
  - r-prettyunits=1.1.1=r43hc72bb7e_3
  - r-processx=3.8.2=r43h57805ef_0
  - r-profvis=0.3.8=r43h57805ef_3
  - r-progress=1.2.2=r43hc72bb7e_4
  - r-proj=0.4.0=r43h57805ef_2
  - r-proj4=1.0_13=r43he1907f6_0
  - r-promises=1.2.1=r43ha503ecb_0
  - r-proxy=0.4_27=r43h57805ef_2
  - r-ps=1.7.5=r43h57805ef_1
  - r-purrr=1.0.2=r43h57805ef_0
  - r-r6=2.5.1=r43hc72bb7e_2
  - r-ragg=1.2.5=r43h85cdef0_2
  - r-rapidjsonr=1.2.0=r43hc72bb7e_3
  - r-rappdirs=0.3.3=r43h57805ef_2
  - r-raster=3.6_23=r43ha503ecb_0
  - r-rcmdcheck=1.4.0=r43h785f33e_2
  - r-rcolorbrewer=1.1_3=r43h785f33e_2
  - r-rcpp=1.0.11=r43h7df8631_0
  - r-rcppeigen=0.3.3.9.3=r43h08d816e_1
  - r-rematch2=2.1.2=r43hc72bb7e_3
  - r-remotes=2.4.2.1=r43hc72bb7e_0
  - r-repr=1.1.6=r43h785f33e_1
  - r-reproj=0.4.3=r43hc72bb7e_1
  - r-rjava=1.0_6=r43h57805ef_7
  - r-rlang=1.1.1=r43ha503ecb_1
  - r-rmarkdown=2.24=r43hc72bb7e_0
  - r-roxygen2=7.2.3=r43ha503ecb_1
  - r-rprojroot=2.0.3=r43hc72bb7e_0
  - r-rstudioapi=0.15.0=r43hc72bb7e_0
  - r-rversions=2.1.2=r43hc72bb7e_2
  - r-rvest=1.0.3=r43hc72bb7e_2
  - r-s2=1.1.4=r43h5eac2b3_1
  - r-sass=0.4.7=r43ha503ecb_0
  - r-satellite=1.0.4=r43ha503ecb_2
  - r-scales=1.2.1=r43hc72bb7e_2
  - r-selectr=0.4_2=r43hc72bb7e_3
  - r-servr=0.27=r43hc72bb7e_1
  - r-sessioninfo=1.2.2=r43hc72bb7e_2
  - r-sf=1.0_14=r43ha912c30_0
  - r-sfheaders=0.4.3=r43ha503ecb_0
  - r-shiny=1.7.5=r43h785f33e_0
  - r-sourcetools=0.1.7_1=r43ha503ecb_1
  - r-sp=2.0_0=r43h57805ef_0
  - r-spatialwidget=0.2.3=r43ha503ecb_2
  - r-stars=0.6_4=r43hc72bb7e_0
  - r-stringi=1.7.12=r43hc0c3e09_2
  - r-stringr=1.5.0=r43h785f33e_1
  - r-svglite=2.1.1=r43h329214f_1
  - r-sys=3.4.2=r43h57805ef_1
  - r-systemfonts=1.0.4=r43haf97adc_2
  - r-terra=1.7_46=r43hace868e_0
  - r-testthat=3.1.10=r43ha503ecb_0
  - r-textshaping=0.3.6=r43h24cd192_6
  - r-tibble=3.2.1=r43h57805ef_2
  - r-tidygeocoder=1.0.5=r43hc72bb7e_2
  - r-tidyselect=1.2.0=r43hc72bb7e_1
  - r-timechange=0.2.0=r43ha503ecb_1
  - r-tinytex=0.46=r43hc72bb7e_0
  - r-tmap=3.3_4=r43hc72bb7e_0
  - r-tmaptools=3.1_1=r43hc72bb7e_2
  - r-units=0.8_4=r43ha503ecb_0
  - r-urlchecker=1.0.1=r43hc72bb7e_2
  - r-usethis=2.2.2=r43hc72bb7e_0
  - r-utf8=1.2.3=r43h57805ef_1
  - r-uuid=1.1_1=r43h57805ef_0
  - r-v8=4.3.3=r43h8e9208c_0
  - r-vctrs=0.6.3=r43ha503ecb_0
  - r-viridis=0.6.4=r43hc72bb7e_0
  - r-viridislite=0.4.2=r43hc72bb7e_1
  - r-waldo=0.5.1=r43hc72bb7e_1
  - r-webshot=0.5.5=r43hc72bb7e_0
  - r-whisker=0.4.1=r43hc72bb7e_1
  - r-widgetframe=0.3.1=r43hc72bb7e_3
  - r-withr=2.5.0=r43hc72bb7e_2
  - r-wk=0.8.0=r43ha503ecb_0
  - r-xfun=0.40=r43ha503ecb_0
  - r-xml=3.99_0.14=r43hc38eee6_2
  - r-xml2=1.3.5=r43h1ad5fc0_0
  - r-xopen=1.0.0=r43hc72bb7e_1005
  - r-xtable=1.8_4=r43hc72bb7e_5
  - r-yaml=2.3.7=r43h57805ef_1
  - r-zip=2.3.0=r43h57805ef_1
  - r5py=0.1.1.dev0=pyhd8ed1ab_0
  - rasterio=1.3.8=py311h41e4db2_0
  - rasterstats=0.19.0=pyhd8ed1ab_0
  - re2=2023.03.02=h8c504da_0
  - readline=8.2=h8228510_1
  - referencing=0.30.2=pyhd8ed1ab_0
  - reproc=14.2.4=h0b41bf4_0
  - reproc-cpp=14.2.4=hcb278e6_0
  - requests=2.31.0=pyhd8ed1ab_0
  - rfc3339-validator=0.1.4=pyhd8ed1ab_0
  - rfc3986-validator=0.1.1=pyh9f0ad1d_0
  - rpds-py=0.10.3=py311h46250e7_0
  - rtree=1.0.1=py311h3bb2b0f_2
  - ruamel.yaml=0.17.32=py311h459d7ec_0
  - ruamel.yaml.clib=0.2.7=py311h2582759_1
  - scikit-learn=1.3.0=py311hc009520_0
  - scipy=1.11.2=py311h64a7726_1
  - seaborn=0.12.2=hd8ed1ab_0
  - seaborn-base=0.12.2=pyhd8ed1ab_0
  - sed=4.8=he412f7d_0
  - segregation=2.5=pyhd8ed1ab_0
  - send2trash=1.8.2=pyh41d4057_0
  - setuptools=68.2.2=pyhd8ed1ab_0
  - shapely=2.0.1=py311he06c224_2
  - simplejson=3.19.1=py311h2582759_0
  - sip=6.7.11=py311hb755f60_0
  - six=1.16.0=pyh6c4a22f_0
  - smmap=3.0.5=pyh44b312d_0
  - snappy=1.1.10=h9fff704_0
  - sniffio=1.3.0=pyhd8ed1ab_0
  - snuggs=1.4.7=py_0
  - soupsieve=2.5=pyhd8ed1ab_1
  - spaghetti=1.7.4=pyhd8ed1ab_0
  - spglm=1.0.8=py_0
  - spint=1.0.7=pyhd8ed1ab_0
  - splot=1.1.5.post1=pyhd8ed1ab_0
  - spopt=0.5.0=pyhd8ed1ab_0
  - spreg=1.3.2=pyhd8ed1ab_0
  - spvcm=0.3.0=py_0
  - sqlite=3.43.0=h2c6b66d_0
  - stack_data=0.6.2=pyhd8ed1ab_0
  - statsmodels=0.14.0=py311h1f0f07a_1
  - sympy=1.12=pypyh9d50eac_103
  - sysroot_linux-64=2.12=he073ed8_16
  - terminado=0.17.1=pyh41d4057_0
  - threadpoolctl=3.2.0=pyha21a80b_0
  - tiledb=2.16.3=h8c794c1_3
  - tinycss2=1.2.1=pyhd8ed1ab_0
  - tk=8.6.12=h27826a3_0
  - tktable=2.10=hb7b940f_3
  - tobler=0.11.1=pyhd8ed1ab_0
  - toml=0.10.2=pyhd8ed1ab_0
  - tomli=2.0.1=pyhd8ed1ab_0
  - toolz=0.12.0=pyhd8ed1ab_0
  - tornado=6.3.3=py311h459d7ec_0
  - tqdm=4.66.1=pyhd8ed1ab_0
  - traitlets=5.9.0=pyhd8ed1ab_0
  - typing-extensions=4.7.1=hd8ed1ab_0
  - typing_extensions=4.7.1=pyha770c72_0
  - typing_utils=0.1.0=pyhd8ed1ab_0
  - tzcode=2023c=h0b41bf4_0
  - tzdata=2023c=h71feb2d_0
  - udunits2=2.2.28=hc3e0081_0
  - uri-template=1.3.0=pyhd8ed1ab_0
  - urllib3=2.0.4=pyhd8ed1ab_0
  - wcwidth=0.2.6=pyhd8ed1ab_0
  - webcolors=1.13=pyhd8ed1ab_0
  - webencodings=0.5.1=py_1
  - websocket-client=1.6.3=pyhd8ed1ab_0
  - wheel=0.41.2=pyhd8ed1ab_0
  - widgetsnbextension=4.0.9=pyhd8ed1ab_0
  - xcb-util=0.4.0=hd590300_1
  - xcb-util-image=0.4.0=h8ee46fc_1
  - xcb-util-keysyms=0.4.0=h8ee46fc_1
  - xcb-util-renderutil=0.3.9=hd590300_1
  - xcb-util-wm=0.4.1=h8ee46fc_1
  - xerces-c=3.2.4=h8d71039_2
  - xkeyboard-config=2.39=hd590300_0
  - xorg-fixesproto=5.0=h7f98852_1002
  - xorg-inputproto=2.3.2=h7f98852_1002
  - xorg-kbproto=1.0.7=h7f98852_1002
  - xorg-libice=1.1.1=hd590300_0
  - xorg-libsm=1.2.4=h7391055_0
  - xorg-libx11=1.8.6=h8ee46fc_0
  - xorg-libxau=1.0.11=hd590300_0
  - xorg-libxdmcp=1.1.3=h7f98852_0
  - xorg-libxext=1.3.4=h0b41bf4_2
  - xorg-libxfixes=5.0.3=h7f98852_1004
  - xorg-libxi=1.7.10=h7f98852_0
  - xorg-libxrender=0.9.11=hd590300_0
  - xorg-libxt=1.3.0=hd590300_1
  - xorg-libxtst=1.2.3=h7f98852_1002
  - xorg-recordproto=1.14.2=h7f98852_1002
  - xorg-renderproto=0.11.1=h7f98852_1002
  - xorg-xextproto=7.3.0=h0b41bf4_1003
  - xorg-xf86vidmodeproto=2.3.1=h7f98852_1002
  - xorg-xproto=7.0.31=h7f98852_1007
  - xyzservices=2023.7.0=pyhd8ed1ab_0
  - xz=5.2.6=h166bdaf_0
  - yaml=0.2.5=h7f98852_2
  - yaml-cpp=0.7.0=h27087fc_2
  - zeromq=4.3.4=h9c3ff4c_1
  - zipp=3.16.2=pyhd8ed1ab_0
  - zlib=1.2.13=hd590300_5
  - zstandard=0.19.0=py311hd4cff14_0
  - zstd=1.5.5=hfc55251_0
  - pip:
      - jellyfish==0.11.2
      - r5py-sampledata-helsinki==0.1.1.dev0
      - r5py-sampledata-sao-paulo==0.1.1.dev0
      - us==3.1.1
```
</details>


System info:
```
LSB Version:	:core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID:	CentOS
Description:	CentOS Linux release 7.9.2009 (Core)
Release:	7.9.2009
Codename:	Core
```

Thank you and I really enjoyed the workshop at GIScience!



Discussion / hints:
Thanks for reporting this issue. This is indeed something we implemented by design, in order to be able to clean temporary data that is left behind by the R5 engine. 

Do you think exposing a config option to have the temp file in a user-chosen location would solve the problem?
Makes sense, yeah just having a config option to set the temporary directory (or using the `_JAVA_OPTIONS: -Djava.io.tmpdir=/data/cigi/scratch/cigi-gisolve` env variable when set) should solve this adequately.

Fix patch:
diff --git a/.gitignore b/.gitignore
index eedd2b79..de81e980 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,3 +37,5 @@ docs/user-guide/user-manual/detailed_itineraries.gpkg
 .coverage
 coverage.xml
 .vscode/*
+
+.config/r5py.yml
diff --git a/docs/user-guide/user-manual/configuration.md b/docs/user-guide/user-manual/configuration.md
index 8eb47dbe..faf3066e 100644
--- a/docs/user-guide/user-manual/configuration.md
+++ b/docs/user-guide/user-manual/configuration.md
@@ -19,20 +19,24 @@ note that in the configuration files the leading dash(es) are omitted (see
 
 ```{eval-rst}
 --max-memory=value, -m value
-              `Set the limit for the Java Virtual Machine’s heap
-              size <advanced-use.html#limit-the-maximum-java-heap-size-memory-use>`_
-              (``-Xmx``).  This option accepts either absolute values (integer or
-              decimal), optionally with a suffix to indicate Mibibytes,
-              Gibibytes, or Tebibytes: ``M``, ``G``, ``T``), or relative, expressed in
-              a percentage of total memory, with a ``%`` suffix. Default: ``80%``
+            `Set the limit for the Java Virtual Machine’s heap
+            size <advanced-use.html#limit-the-maximum-java-heap-size-memory-use>`_
+            (``-Xmx``).  This option accepts either absolute values (integer or
+            decimal), optionally with a suffix to indicate Mibibytes,
+            Gibibytes, or Tebibytes: ``M``, ``G``, ``T``), or relative, expressed in
+            a percentage of total memory, with a ``%`` suffix. Default: ``80%``
 
 --r5-classpath=classpath, -r classpath
-              Point to R⁵’s JAR (or build directory) in case you want to use a
-              `custom R⁵ installation <advanced-use.html#use-a-custom-installation-of-r5>`_ .
-              Default: ``""`` (download latest compatible version of R5)
+            Point to R⁵’s JAR (or build directory) in case you want to use a
+            `custom R⁵ installation <advanced-use.html#use-a-custom-installation-of-r5>`_ .
+            Default: ``""`` (download latest compatible version of R5)
+
+--temporary-directory=temp_dir, -t temp_dir
+            Override the system’s default temporary directory. Default: ``""``
+            (use system default)
 
 --verbose, -v
-              Show more detailed output.
+            Show more detailed output.
 ```
 
 
diff --git a/src/r5py/util/config.py b/src/r5py/util/config.py
index 00352d12..1a8b7eb7 100644
--- a/src/r5py/util/config.py
+++ b/src/r5py/util/config.py
@@ -130,7 +130,17 @@ def get_arguments(self, ignore_help_args=False):
 
     @functools.cached_property
     def TEMP_DIR(self):
-        temp_dir = pathlib.Path(tempfile.mkdtemp(prefix=self.PACKAGE))
+        parent_dir = self.arguments.temporary_directory
+        temp_dir = pathlib.Path(tempfile.mkdtemp(prefix=self.PACKAGE), dir=parent_dir)
         return temp_dir
 
     PACKAGE = PACKAGE
+
+
+Config().argparser.add(
+    "-t",
+    "--temporary-directory",
+    help="Directory for temporary files, overrides system default",
+    default=None,
+    type=pathlib.Path,
+)


Test patch:
diff --git a/tests/test_config.py b/tests/test_config.py
index a67b981b..6f78d44a 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -3,6 +3,7 @@
 
 import importlib
 import os
+import sys
 
 import r5py.util.config
 
@@ -12,3 +13,15 @@ def test_setdefaulthome(self):
         del os.environ["HOME"]
         importlib.reload(r5py.util.config)
         assert os.environ["HOME"] == "."
+
+    def test_custom_temporary_directory(self, tmp_path):
+        sys.argv.extend(
+            [
+                "--temporary-directory",
+                f"{tmp_path}",
+            ]
+        )
+        assert r5py.util.config.Config().arguments.temporary_directory.is_relative_to(
+            tmp_path
+        )
+        sys.argv = sys.argv[:-2]