> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wherobots.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GDAL configuration

> Read rasters on S3 with rasterio using the S3 configuration of the Spark session.

```python theme={"system"}
from sedona.spark.raster import gdal_conf
```

## clear\_gdal\_conf\_from\_env

```python theme={"system"}
clear_gdal_conf_from_env()
```

Remove the environment variables set by `export_gdal_conf_to_env`.

#### Raises

* `KeyError`: If the variables are not set.

## export\_gdal\_conf\_to\_env

```python theme={"system"}
export_gdal_conf_to_env()
```

Export the GDAL configuration to environment variables for subprocesses.

Sedona reads the S3 configuration of out-db rasters from the Spark session,
which a subprocess cannot see. Call this before starting subprocesses that
read out-db rasters, so that they load the configuration from the
environment instead. Variables that are already set are left unchanged.

## get\_gdal\_conf

```python theme={"system"}
get_gdal_conf(path: str) -> Dict[str, str]
```

GDAL configuration options for reading `path`.

#### Parameters

<ParamField path="path" type="str" required>
  Path of the file to read. A path starting with `s3://`, `s3a://` or
  `/vsis3/` gets the options of its bucket; see
  `get_gdal_conf_for_s3_bucket`.
</ParamField>

#### Returns

<ResponseField name="return" type="dict of str to str">
  GDAL configuration options, or an empty dict for other paths.
</ResponseField>

## get\_gdal\_conf\_for\_s3\_bucket

```python theme={"system"}
get_gdal_conf_for_s3_bucket(bucket_name: str) -> Dict[str, str]
```

GDAL configuration options for reading from an S3 bucket.

The options come from the Spark session's `spark.hadoop.fs.s3a.*`
configuration, using the bucket's own `spark.hadoop.fs.s3a.bucket.<bucket>.*`
settings when it has them, or from the environment variables set by
`export_gdal_conf_to_env`. Assumed-role credentials are resolved into
`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` and `AWS_SESSION_TOKEN`.

#### Parameters

<ParamField path="bucket_name" type="str" required>
  Name of the S3 bucket.
</ParamField>

#### Returns

<ResponseField name="return" type="dict of str to str">
  GDAL configuration options, or an empty dict if there is no configuration.
</ResponseField>

## get\_rasterio\_aws\_session

```python theme={"system"}
get_rasterio_aws_session(path: str) -> Optional[AWSSession]
```

A rasterio AWS session with the credentials Sedona uses to read `path`.

Pass it to `rasterio.Env(session=...)` to open files on S3 with rasterio
using the same configuration as Sedona's out-db rasters.

#### Parameters

<ParamField path="path" type="str" required>
  Path of the file to read.
</ParamField>

#### Returns

<ResponseField name="return" type="rasterio.session.AWSSession or None">
  The session, or None if there is no configuration for `path` or
  `boto3` is not installed.
</ResponseField>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.